[Orxonox-commit 1238] r5956 - in code/branches/sound3/src/orxonox: . gamestates

youngk at orxonox.net youngk at orxonox.net
Wed Oct 14 17:01:49 CEST 2009


Author: youngk
Date: 2009-10-14 17:01:49 +0200 (Wed, 14 Oct 2009)
New Revision: 5956

Added:
   code/branches/sound3/src/orxonox/MoodManager.cc
   code/branches/sound3/src/orxonox/MoodManager.h
Modified:
   code/branches/sound3/src/orxonox/CMakeLists.txt
   code/branches/sound3/src/orxonox/gamestates/GSMainMenu.cc
   code/branches/sound3/src/orxonox/gamestates/GSMainMenu.h
Log:
Implemented Mood functionality plus the ability to change the background sound in the main menu

Modified: code/branches/sound3/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/sound3/src/orxonox/CMakeLists.txt	2009-10-14 15:00:48 UTC (rev 5955)
+++ code/branches/sound3/src/orxonox/CMakeLists.txt	2009-10-14 15:01:49 UTC (rev 5956)
@@ -27,6 +27,7 @@
   Level.cc
   LevelManager.cc
   Main.cc
+  MoodManager.cc
   PawnManager.cc
   PlayerManager.cc
   Radar.cc
@@ -54,6 +55,7 @@
   FIND_HEADER_FILES
   TOLUA_FILES
     LevelManager.h
+    MoodManager.h
     pickup/BaseItem.h
     pickup/PickupInventory.h
   DEFINE_SYMBOL

Added: code/branches/sound3/src/orxonox/MoodManager.cc
===================================================================
--- code/branches/sound3/src/orxonox/MoodManager.cc	                        (rev 0)
+++ code/branches/sound3/src/orxonox/MoodManager.cc	2009-10-14 15:01:49 UTC (rev 5956)
@@ -0,0 +1,67 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Kevin 'youngk' Young
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "MoodManager.h"
+
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
+
+namespace orxonox
+{
+    MoodManager* MoodManager::singletonPtr_s = 0;
+    ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+
+    MoodManager::MoodManager()
+    {
+        RegisterRootObject(MoodManager);
+        this->setConfigValues();
+		CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&MoodManager::setMood, this), "setMood"));
+    }
+
+    MoodManager::~MoodManager()
+    {
+    }
+
+    void MoodManager::setConfigValues()
+    {
+        SetConfigValue(mood_, "default")
+            .description("Sets the mood for the current level.");
+    }
+
+	// sets a new mood
+	void MoodManager::setMood(const std::string& mood) {
+		ModifyConfigValue(mood_, set, mood);
+	}
+	
+	// gets the current mood
+	const std::string& MoodManager::getMood() {
+		return mood_;
+	}
+}

Added: code/branches/sound3/src/orxonox/MoodManager.h
===================================================================
--- code/branches/sound3/src/orxonox/MoodManager.h	                        (rev 0)
+++ code/branches/sound3/src/orxonox/MoodManager.h	2009-10-14 15:01:49 UTC (rev 5956)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Kevin 'youngk' Young
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _MoodManager_H__
+#define _MoodManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <cassert>
+#include <list>
+#include <string>
+
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+
+// tolua_begin
+namespace orxonox
+{
+    class _OrxonoxExport MoodManager
+    // tolua_end
+        : public Singleton<MoodManager>, public OrxonoxClass
+    { // tolua_export
+            friend class Singleton<MoodManager>;
+        public:
+            MoodManager();
+            ~MoodManager();
+
+            void setConfigValues();
+
+			void setMood(const std::string& mood);
+			const std::string& getMood();
+
+            static MoodManager& getInstance()    { return Singleton<MoodManager>::getInstance(); } // tolua_export
+
+        private:
+           
+            // config values
+            std::string mood_;
+
+            static MoodManager* singletonPtr_s;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _MoodManager_H__ */

Modified: code/branches/sound3/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/sound3/src/orxonox/gamestates/GSMainMenu.cc	2009-10-14 15:00:48 UTC (rev 5955)
+++ code/branches/sound3/src/orxonox/gamestates/GSMainMenu.cc	2009-10-14 15:01:49 UTC (rev 5956)
@@ -35,6 +35,7 @@
 #include "core/input/KeyBinderManager.h"
 #include "core/Game.h"
 #include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
 #include "core/GraphicsManager.h"
 #include "core/GUIManager.h"
 #include "Scene.h"
@@ -48,6 +49,7 @@
         : GameState(info)
         , inputState_(0)
     {
+		RegisterRootObject(GSMainMenu);
         inputState_ = InputManager::getInstance().createInputState("mainMenu");
         inputState_->setMouseMode(MouseMode::Nonexclusive);
         inputState_->setHandler(GUIManager::getInstancePtr());
@@ -63,7 +65,6 @@
         {
             // Load sound
             this->ambient_ = new AmbientSound(0);
-            this->ambient_->setSource("ambient/mainmenu.wav");
         }
     }
 
@@ -91,6 +92,9 @@
         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startIOConsole), "startIOConsole"));
+		
+		// create command to change sound path
+		CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
 
         KeyBinderManager::getInstance().setToDefault();
         InputManager::getInstance().enterState("mainMenu");
@@ -98,8 +102,10 @@
         if (GameMode::playsSound())
         {
             this->ambient_->setLoop(true);
-            this->ambient_->play();
+			this->ambient_->setPlayOnLoad(true);
         }
+
+		this->setConfigValues();
     }
 
     void GSMainMenu::deactivate()
@@ -119,6 +125,28 @@
     {
     }
 
+	void GSMainMenu::setConfigValues()
+    {
+        SetConfigValue(soundPathMain_, "ambient/mainmenu.wav")
+            .description("Contains the path to the main menu sound file.")
+			.callback(this, &GSMainMenu::reloadSound);
+    }
+
+	void GSMainMenu::reloadSound() {
+		if (GameMode::playsSound())
+        {
+			this->ambient_->setSource(soundPathMain_);
+		}
+	}
+
+	const std::string& GSMainMenu::getMainMenuSoundPath() {
+		return soundPathMain_;
+	}
+
+	void GSMainMenu::setMainMenuSoundPath(const std::string& path) {
+		ModifyConfigValue(soundPathMain_, set, path);
+	}
+
     void GSMainMenu::startStandalone()
     {
         // HACK - HACK

Modified: code/branches/sound3/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/branches/sound3/src/orxonox/gamestates/GSMainMenu.h	2009-10-14 15:00:48 UTC (rev 5955)
+++ code/branches/sound3/src/orxonox/gamestates/GSMainMenu.h	2009-10-14 15:01:49 UTC (rev 5956)
@@ -33,10 +33,11 @@
 
 #include "util/OgreForwardRefs.h"
 #include "core/GameState.h"
+#include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSMainMenu : public GameState
+    class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass
     {
     public:
         GSMainMenu(const GameStateInfo& info);
@@ -46,6 +47,11 @@
         void deactivate();
         void update(const Clock& time);
 
+		void setConfigValues();
+		void reloadSound();
+		const std::string& getMainMenuSoundPath();
+		void setMainMenuSoundPath(const std::string& path);
+
         static void startStandalone();
         static void startServer();
         static void startClient();
@@ -60,6 +66,7 @@
 
         // ambient sound for the main menu
         AmbientSound*     ambient_;
+		std::string		  soundPathMain_;
     };
 }
 




More information about the Orxonox-commit mailing list