Changeset 2850
- Timestamp:
- Mar 25, 2009, 11:53:04 PM (16 years ago)
- Location:
- code/branches/gui
- Files:
-
- 26 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/bin/client1.bat.in
r2799 r2850 1 1 title @PROJECT_NAME@ 2 2 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path% 3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ -- stateclient --writingPathSuffix client13 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client1 4 4 pause -
code/branches/gui/bin/client1.in
r2799 r2850 2 2 # convenience script for starting orxonox on Linux 3 3 4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ -- stateclient --writingPathSuffix client1 $@4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client1 $@ -
code/branches/gui/bin/client2.bat.in
r2799 r2850 1 1 title @PROJECT_NAME@ 2 2 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path% 3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ -- stateclient --writingPathSuffix client23 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client2 4 4 pause -
code/branches/gui/bin/client2.in
r2799 r2850 2 2 # convenience script for starting orxonox on Linux 3 3 4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ -- stateclient --writingPathSuffix client2 $@4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --client --writingPathSuffix client2 $@ -
code/branches/gui/bin/dedicated.bat.in
r2799 r2850 1 1 title @PROJECT_NAME@ 2 2 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path% 3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ -- statededicated --writingPathSuffix dedicated3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --dedicated --writingPathSuffix dedicated 4 4 pause -
code/branches/gui/bin/dedicated.in
r2799 r2850 2 2 # convenience script for starting orxonox on Linux 3 3 4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ -- statededicated --writingPathSuffix dedicated $@4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --dedicated --writingPathSuffix dedicated $@ -
code/branches/gui/bin/server.bat.in
r2799 r2850 1 1 title @PROJECT_NAME@ 2 2 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path% 3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --s tate server --writingPathSuffix server3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --server --writingPathSuffix server 4 4 pause -
code/branches/gui/bin/server.in
r2799 r2850 2 2 # convenience script for starting orxonox on Linux 3 3 4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --s tate server --writingPathSuffix server $@4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --server --writingPathSuffix server $@ -
code/branches/gui/bin/standalone.bat.in
r2799 r2850 1 1 title @PROJECT_NAME@ 2 2 path @ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS@;%path% 3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --sta te standalone --writingPathSuffix standalone3 @CURRENT_RUNTIME_DIR_WINDOWS@\@ORXONOX_EXECUTABLE_NAME@ --standalone --writingPathSuffix standalone 4 4 pause -
code/branches/gui/bin/standalone.in
r2799 r2850 2 2 # convenience script for starting orxonox on Linux 3 3 4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --sta te standalone --writingPathSuffix standalone $@4 exec @CURRENT_RUNTIME_DIR@/@ORXONOX_EXECUTABLE_NAME@ --standalone --writingPathSuffix standalone $@ -
code/branches/gui/src/core/Game.cc
r2846 r2850 40 40 #include "util/Debug.h" 41 41 #include "util/Exception.h" 42 #include "util/SubString.h" 42 43 #include "Clock.h" 43 44 #include "CommandLine.h" … … 247 248 // Check parent and all its grand parents 248 249 GameStateTreeNode* currentNode = lastRequestedNode; 249 while (requestedNode == NULL && currentNode ->parent_!= NULL)250 while (requestedNode == NULL && currentNode != NULL) 250 251 { 251 252 if (currentNode->state_ == state) … … 260 261 } 261 262 263 void Game::requestStates(const std::string& names) 264 { 265 SubString tokens(names, ",;", " "); 266 for (unsigned int i = 0; i < tokens.size(); ++i) 267 this->requestState(tokens[i]); 268 } 269 262 270 void Game::popState() 263 271 { … … 270 278 GameState* Game::getState(const std::string& name) 271 279 { 272 std::map<std::string, GameState*>::const_iterator it = allStates_s.find( name);280 std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(name)); 273 281 if (it != allStates_s.end()) 274 282 return it->second; … … 356 364 void Game::loadState(GameState* state) 357 365 { 366 if (!this->activeStates_.empty()) 367 this->activeStates_.back()->activity_.topState = false; 358 368 state->activate(); 369 state->activity_.topState = true; 359 370 this->activeStates_.push_back(state); 360 371 } … … 362 373 void Game::unloadState(orxonox::GameState* state) 363 374 { 375 state->activity_.topState = false; 364 376 state->deactivate(); 365 377 this->activeStates_.pop_back(); 378 if (!this->activeStates_.empty()) 379 this->activeStates_.back()->activity_.topState = true; 366 380 } 367 381 368 382 /*static*/ bool Game::addGameState(GameState* state) 369 383 { 370 std::map<std::string, GameState*>::const_iterator it = allStates_s.find( state->getName());384 std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(state->getName())); 371 385 if (it == allStates_s.end()) 372 allStates_s[ state->getName()] = state;386 allStates_s[getLowercase(state->getName())] = state; 373 387 else 374 388 ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'."); -
code/branches/gui/src/core/Game.h
r2846 r2850 66 66 67 67 void requestState(const std::string& name); 68 void requestStates(const std::string& names); 68 69 void popState(); 69 70 -
code/branches/gui/src/core/GameState.cc
r2844 r2850 49 49 , parent_(0) 50 50 { 51 State temp = {false, false, false, false, false}; 52 this->activity_ = temp; 51 this->activity_.activating = false; 52 this->activity_.active = false; 53 this->activity_.deactivating = false; 54 this->activity_.suspended = false; 55 this->activity_.topState = false; 56 this->activity_.updating = false; 53 57 } 54 58 -
code/branches/gui/src/core/GameState.h
r2844 r2850 74 74 unsigned updating : 1; 75 75 unsigned suspended : 1; 76 unsigned topState : 1; 76 77 }; 77 78 … … 81 82 82 83 const std::string& getName() const { return name_; } 83 constState getActivity() const { return this->activity_; }84 State getActivity() const { return this->activity_; } 84 85 GameState* getParent() const { return this->parent_; } 85 86 -
code/branches/gui/src/orxonox/CameraManager.cc
r2848 r2850 142 142 143 143 this->viewport_->setCamera(camera); 144 GUIManager::getInstance Ptr()->setCamera(camera);144 GUIManager::getInstance().setCamera(camera); 145 145 146 146 // reactivate all visible compositors -
code/branches/gui/src/orxonox/GraphicsManager.cc
r2848 r2850 216 216 } 217 217 218 void GraphicsManager::setCamera(Ogre::Camera* camera) 219 { 220 this->viewport_->setCamera(camera); 221 } 222 218 223 /** 219 224 @brief -
code/branches/gui/src/orxonox/GraphicsManager.h
r2817 r2850 66 66 { return this->detailLevelParticle_; } 67 67 68 inline void setViewport(Ogre::Viewport* viewport)69 { this->viewport_ = viewport; }70 68 inline Ogre::Viewport* getViewport() const 71 69 { return this->viewport_; } … … 73 71 { return this->renderWindow_; } 74 72 73 void setCamera(Ogre::Camera* camera); 74 75 75 static GraphicsManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 76 77 76 78 77 private: -
code/branches/gui/src/orxonox/gamestates/CMakeLists.txt
r2710 r2850 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 GSClient.cc 2 3 GSDedicated.cc 3 GSClient.cc4 4 GSGraphics.cc 5 GSGUI.cc6 5 GSIOConsole.cc 7 6 GSLevel.cc 7 GSMainMenu.cc 8 8 GSRoot.cc 9 9 GSServer.cc -
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r2848 r2850 35 35 #include "util/Debug.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "core/Clock.h" 37 38 #include "core/Core.h" 38 39 #include "core/CoreIncludes.h" … … 146 147 this->inputManager_->update(time); // tick console 147 148 this->console_->update(time); 149 this->guiManager_->update(time); 148 150 149 151 uint64_t timeAfterTick = time.getRealMicroseconds(); … … 152 154 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 153 155 156 // Render 154 157 this->graphicsManager_->update(time); 155 158 } -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
r2844 r2850 53 53 void GSIOConsole::activate() 54 54 { 55 { 56 FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu); 57 functor->setObject(this); 58 this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu"); 59 CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_); 60 } 55 61 } 56 62 57 63 void GSIOConsole::deactivate() 58 64 { 65 if (this->ccLoadMenu_) 66 { 67 delete this->ccLoadMenu_; 68 this->ccLoadMenu_ = 0; 69 } 59 70 } 60 71 61 72 void GSIOConsole::update(const Clock& time) 62 73 { 74 std::cout << ">"; 63 75 std::string command; 64 76 std::getline(std::cin, command); 65 77 CommandExecutor::execute(command, true); 66 78 } 79 80 void GSIOConsole::loadMenu() 81 { 82 Game::getInstance().popState(); 83 Game::getInstance().requestStates("graphics, mainMenu"); 84 } 67 85 } -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
r2844 r2850 46 46 47 47 private: 48 void loadMenu(); 48 49 50 // console commands 51 ConsoleCommand* ccLoadMenu_; 49 52 }; 50 53 } -
code/branches/gui/src/orxonox/gamestates/GSLevel.cc
r2848 r2850 49 49 #include "LevelManager.h" 50 50 #include "PlayerManager.h" 51 #include "gui/GUIManager.h" 51 52 52 53 namespace orxonox … … 86 87 if (GameMode::showsGraphics()) 87 88 { 89 { 90 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::toggleGUI); 91 functor->setObject(this); 92 this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI"); 93 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_); 94 } 95 88 96 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game"); 89 97 keyBinder_ = new KeyBinder(); … … 110 118 if (GameMode::showsGraphics()) 111 119 { 112 // TODO: insert slomo console command with113 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);114 115 120 // keybind console command 116 121 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); … … 125 130 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); 126 131 132 // InGame GUI test 133 GUIManager::getInstance().showGUI("inGameTest"); 134 127 135 // level is loaded: we can start capturing the input 128 136 InputManager::getInstance().requestEnterState("game"); … … 143 151 this->ccTkeybind_ = 0; 144 152 } 153 if (this->ccToggleGUI_) 154 { 155 delete this->ccToggleGUI_; 156 this->ccToggleGUI_ = 0; 157 } 158 145 159 146 160 // this call will delete every BaseObject! … … 219 233 220 234 delete this->startFile_; 235 } 236 237 void GSLevel::toggleGUI() 238 { 239 if (GameMode::showsGraphics()) 240 { 241 GUIManager::getInstance().executeCode("toggleGUI()"); 242 } 221 243 } 222 244 -
code/branches/gui/src/orxonox/gamestates/GSLevel.h
r2844 r2850 47 47 void update(const Clock& time); 48 48 49 void toggleGUI(); 50 49 51 protected: 50 52 void loadLevel(); … … 70 72 ConsoleCommand* ccKeybind_; 71 73 ConsoleCommand* ccTkeybind_; 72 74 ConsoleCommand* ccToggleGUI_; 73 75 }; 74 76 } -
code/branches/gui/src/orxonox/gamestates/GSMainMenu.cc
r2848 r2850 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "GS GUI.h"30 #include "GSMainMenu.h" 31 31 32 #include <OgreViewport.h> 32 //#include <OgreViewport.h> 33 #include <OgreSceneManager.h> 33 34 #include "core/Clock.h" 34 35 #include "core/ConsoleCommand.h" … … 37 38 #include "core/input/SimpleInputState.h" 38 39 #include "gui/GUIManager.h" 40 #include "objects/Scene.h" 39 41 #include "GraphicsManager.h" 40 42 41 43 namespace orxonox 42 44 { 43 AddGameState(GS GUI, "mainMenu");45 AddGameState(GSMainMenu, "mainMenu"); 44 46 45 GS GUI::GSGUI(const std::string& name)47 GSMainMenu::GSMainMenu(const std::string& name) 46 48 : GameState(name) 49 , inputState_(0) 47 50 { 48 51 } 49 52 50 GS GUI::~GSGUI()53 GSMainMenu::~GSMainMenu() 51 54 { 52 55 } 53 56 54 void GS GUI::activate()57 void GSMainMenu::activate() 55 58 { 56 guiManager_ = GUIManager::getInstancePtr(); 59 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu"); 60 inputState_->setHandler(GUIManager::getInstancePtr()); 61 inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER); 62 63 // create an empty Scene 64 this->scene_ = new Scene(0); 65 // and a Camera 66 this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); 57 67 58 68 // show main menu 59 //guiManager_->loadScene("MainMenu");60 guiManager_->showGUI("MainMenu", 0);61 GraphicsManager::getInstance(). getViewport()->setCamera(guiManager_->getCamera());69 GUIManager::getInstance().showGUI("mainMenu"); 70 GUIManager::getInstance().setCamera(this->camera_); 71 GraphicsManager::getInstance().setCamera(this->camera_); 62 72 63 73 { 64 // time factor console command 65 FunctorMember<GSGUI>* functor = createFunctor(&GSGUI::startGame); 74 FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame); 66 75 functor->setObject(this); 67 76 this->ccStartGame_ = createConsoleCommand(functor, "startGame"); 68 77 CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_); 69 78 } 79 80 InputManager::getInstance().requestEnterState("mainMenu"); 70 81 } 71 82 72 void GS GUI::deactivate()83 void GSMainMenu::deactivate() 73 84 { 85 InputManager::getInstance().requestLeaveState("game"); 86 InputManager::getInstance().requestDestroyState("game"); 87 74 88 if (this->ccStartGame_) 75 89 { … … 78 92 } 79 93 80 guiManager_->hideGUI();94 GUIManager::getInstance().executeCode("hideGUI()"); 81 95 } 82 96 83 void GS GUI::update(const Clock& time)97 void GSMainMenu::update(const Clock& time) 84 98 { 85 // tick CEGUI86 guiManager_->update(time);87 99 } 88 100 89 void GS GUI::startGame()101 void GSMainMenu::startGame() 90 102 { 91 103 // HACK - HACK 92 104 Game::getInstance().popState(); 93 Game::getInstance().requestState("standalone"); 94 Game::getInstance().requestState("level"); 105 Game::getInstance().requestStates("standalone, level"); 95 106 } 96 107 } -
code/branches/gui/src/orxonox/gamestates/GSMainMenu.h
r2844 r2850 27 27 */ 28 28 29 #ifndef _GS GUI_H__30 #define _GS GUI_H__29 #ifndef _GSMainMenu_H__ 30 #define _GSMainMenu_H__ 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h> 33 34 #include "core/GameState.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GS GUI: public GameState38 class _OrxonoxExport GSMainMenu : public GameState 38 39 { 39 40 public: 40 GS GUI(const std::string& name);41 ~GS GUI();41 GSMainMenu(const std::string& name); 42 ~GSMainMenu(); 42 43 43 44 void activate(); … … 48 49 49 50 private: 50 GUIManager* guiManager_; 51 SimpleInputState* inputState_; 52 Scene* scene_; 53 Ogre::Camera* camera_; 51 54 52 55 // console commands … … 55 58 } 56 59 57 #endif /* _GS GUI_H__ */60 #endif /* _GSMainMenu_H__ */ -
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r2848 r2850 44 44 { 45 45 AddGameState(GSRoot, "root"); 46 SetCommandLineSwitch(startWithConsole); 46 SetCommandLineSwitch(console); 47 // Shortcuts for easy direct loading 48 SetCommandLineSwitch(server); 49 SetCommandLineSwitch(client); 50 SetCommandLineSwitch(dedicated); 51 SetCommandLineSwitch(standalone); 47 52 48 53 GSRoot::GSRoot(const std::string& name) … … 63 68 { 64 69 // reset game speed to normal 65 t imeFactor_ = 1.0f;70 this->timeFactor_ = 1.0f; 66 71 67 72 { … … 81 86 } 82 87 88 // Load level directly? 89 bool loadLevel = false; 90 if (CommandLine::getValue("standalone").getBool()) 91 { 92 Game::getInstance().requestStates("graphics, standalone, level"); 93 loadLevel = true; 94 } 95 if (CommandLine::getValue("server").getBool()) 96 { 97 Game::getInstance().requestStates("graphics, server, level"); 98 loadLevel = true; 99 } 100 if (CommandLine::getValue("client").getBool()) 101 { 102 Game::getInstance().requestStates("graphics, standalone, level"); 103 loadLevel = true; 104 } 105 if (CommandLine::getValue("dedicated").getBool()) 106 { 107 Game::getInstance().requestStates("dedicated, level"); 108 loadLevel = true; 109 } 110 83 111 // Determine where to start 84 if (CommandLine::getValue("startWithConsole").getBool()) 85 { 86 // Start the game in the console 87 Game::getInstance().requestState("ioConsole"); 88 } 89 else 90 { 91 // Start in GUI main menu 92 Game::getInstance().requestState("graphics"); 93 Game::getInstance().requestState("mainMenu"); 94 } 95 112 if (!loadLevel) 113 { 114 if (CommandLine::getValue("console").getBool()) 115 { 116 // Start the game in the console without 3D graphics 117 Game::getInstance().requestState("ioConsole"); 118 } 119 else 120 { 121 // Start in GUI mode 122 Game::getInstance().requestStates("graphics, mainMenu"); 123 } 124 } 96 125 } 97 126 … … 113 142 void GSRoot::update(const Clock& time) 114 143 { 144 if (this->getActivity().topState) 145 { 146 // This state can not 'survive' on its own. 147 // Load a user interface therefore 148 Game::getInstance().requestState("ioConsole"); 149 } 150 115 151 uint64_t timeBeforeTick = time.getRealMicroseconds(); 116 152 … … 132 168 uint64_t timeAfterTick = time.getRealMicroseconds(); 133 169 134 // Also add our tick time to the list in GSRoot170 // Also add our tick time 135 171 Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick); 136 172 } -
code/branches/gui/src/orxonox/gui/GUIManager.cc
r2841 r2850 36 36 #include "GUIManager.h" 37 37 38 #include <boost/filesystem .hpp>38 #include <boost/filesystem/path.hpp> 39 39 #include <OgreRenderWindow.h> 40 #include <OgreRoot.h>41 40 #include <CEGUI.h> 42 41 #include <CEGUIDefaultLogger.h> … … 50 49 51 50 #include "util/Exception.h" 52 #include "core/input/InputManager.h"53 #include "core/input/SimpleInputState.h"54 51 #include "core/ConsoleCommand.h" 55 52 #include "core/Core.h" 53 #include "core/Clock.h" 56 54 #include "ToluaBindCore.h" 57 55 #include "ToluaBindOrxonox.h" … … 63 61 namespace orxonox 64 62 { 65 SetConsoleCommandShortcut(GUIManager, toggleGUI).keybindMode(KeybindMode::OnPress);66 67 63 GUIManager* GUIManager::singletonRef_s = 0; 68 64 69 65 GUIManager::GUIManager() 70 //: emptySceneManager_(0) 71 : backgroundSceneManager_(0) 72 //, emptyCamera_(0) 73 , backgroundCamera_(0) 74 //, viewport_(0) 75 , renderWindow_(0) 66 : renderWindow_(0) 76 67 , guiRenderer_(0) 77 68 , resourceProvider_(0) … … 86 77 GUIManager::~GUIManager() 87 78 { 88 if (backgroundCamera_)89 backgroundSceneManager_->destroyCamera(backgroundCamera_);90 91 if (backgroundSceneManager_)92 {93 // We have to make sure the SceneManager is not anymore referenced.94 // For the case that the target SceneManager was yet another one, it95 // wouldn't matter anyway since this is the destructor.96 guiRenderer_->setTargetSceneManager(0);97 Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);98 }99 100 InputManager::getInstance().requestDestroyState("gui");101 102 79 if (guiSystem_) 103 80 delete guiSystem_; … … 110 87 lua_pushnil(luaState_); 111 88 lua_setglobal(luaState_, "Core"); 112 // TODO: deleting the script module fails an assertion.113 // However there is not much we can do about it since it occurs too when114 // we don't open Core or Orxonox. Might be a CEGUI issue.115 // The memory leak is not a problem anyway..116 89 delete scriptModule_; 117 90 } … … 134 107 // save the render window 135 108 renderWindow_ = renderWindow; 136 137 // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)138 //this->viewport_ = renderWindow_->addViewport(0, 3);139 //this->viewport_->setOverlaysEnabled(false);140 //this->viewport_->setShadowsEnabled(false);141 //this->viewport_->setSkiesEnabled(false);142 //this->viewport_->setClearEveryFrame(false);143 109 144 110 // Note: No SceneManager specified yet … … 166 132 tolua_Orxonox_open(this->scriptModule_->getLuaState()); 167 133 168 // register us as input handler 169 SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui"); 170 state->setHandler(this); 171 state->setJoyStickHandler(&InputManager::EMPTY_HANDLER); 172 173 // load the background scene 174 loadScenes(); 175 //CEGUI::KeyEventArgs e; 176 //e.codepoint 134 // initialise the basic lua code 135 loadLuaCode(); 177 136 } 178 137 catch (CEGUI::Exception& ex) … … 187 146 188 147 state_ = Ready; 189 190 148 } 191 149 … … 193 151 } 194 152 195 void GUIManager::loadScene(const std::string& name) 196 { 197 if (name.compare("IngameMenu") == 0) 198 { 199 try 200 { 201 /*this->scriptModule_ = new LuaScriptModule(); 202 this->luaState_ = this->scriptModule_->getLuaState(); 203 this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_); 204 tolua_Core_open(this->scriptModule_->getLuaState()); 205 tolua_Orxonox_open(this->scriptModule_->getLuaState()); 206 */ 207 this->scriptModule_->executeScriptFile("loadGUI_2.lua", "GUI"); 208 } 209 catch (CEGUI::Exception& ex) 210 { 211 #if CEGUI_VERSION_MINOR < 6 212 throw GeneralException(ex.getMessage().c_str()); 213 #else 214 throw GeneralException(ex.getMessage().c_str(), ex.getLine(), 215 ex.getFileName().c_str(), ex.getName().c_str()); 216 #endif 217 } 218 } 219 else 220 { 221 loadScenes(); 222 } 223 } 224 225 void GUIManager::loadScenes() 226 { 227 // first of all, we need to have our own SceneManager for the GUI. The reason 228 // is that we might have multiple viewports when in play mode (e.g. the view of 229 // a camera fixed at the back of the ship). That forces us to create our own 230 // full screen viewport that is on top of all the others, but doesn't clear the 231 // port before rendering, so everything from the GUI gets on top eventually. 232 // But in order to realise that, we also need a SceneManager with an empty scene, 233 // because the SceneManager is responsible for the render queue. 234 //this->emptySceneManager_ = Ogre::Root::getSingleton() 235 // .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager"); 236 237 // we also need a camera or we won't see anything at all. 238 // The camera settings don't matter at all for an empty scene since the GUI 239 // gets rendered on top of the screen rather than into the scene. 240 //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera"); 241 242 // Create another SceneManager that enables to display some 3D 243 // scene in the background of the main menu. 244 this->backgroundSceneManager_ = Ogre::Root::getSingleton() 245 .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager"); 246 this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera"); 247 248 // TODO: create something 3D 153 void GUIManager::loadLuaCode() 154 { 249 155 try 250 156 { … … 264 170 } 265 171 266 void GUIManager::toggleGUI() 267 { 268 //COUT(0) << "********* TOGGLE TOGGLE **********" << std::endl; 269 if (getInstance().scriptModule_->executeScriptGlobal("toggleGUI")) 270 InputManager::getInstance().requestEnterState("gui"); 271 else 272 InputManager::getInstance().requestLeaveState("gui"); 172 void GUIManager::update(const Clock& time) 173 { 174 assert(guiSystem_); 175 guiSystem_->injectTimePulse(time.getDeltaTime()); 176 } 177 178 void GUIManager::executeCode(const std::string& str) 179 { 180 this->scriptModule_->executeString(str); 273 181 } 274 182 … … 278 186 } 279 187 280 void GUIManager::showGUI(const std::string& name , Ogre::SceneManager* sceneManager)// bool showBackground)188 void GUIManager::showGUI(const std::string& name) 281 189 { 282 190 if (state_ != Uninitialised) 283 191 { 284 if (state_ == OnDisplay)285 hideGUI();286 287 192 COUT(3) << "Loading GUI " << name << std::endl; 288 193 try 289 194 { 290 // COUT (0) << "************* sceneManager: " << sceneManager << std::endl; 291 if (!sceneManager) 292 { 293 // currently, only an image is loaded. We could do 3D, see loadBackground. 294 //this->viewport_->setClearEveryFrame(true); 295 this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_); 296 //this->viewport_->setCamera(this->backgroundCamera_); 297 298 lua_pushboolean(this->scriptModule_->getLuaState(), true); 299 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 300 } 301 else 302 { 303 //this->viewport_->setClearEveryFrame(false); 304 this->guiRenderer_->setTargetSceneManager(sceneManager); 305 currentSceneManager_ = sceneManager; 306 //this->viewport_->setCamera(this->emptyCamera_); 307 308 lua_pushboolean(this->scriptModule_->getLuaState(), false); 309 lua_setglobal(this->scriptModule_->getLuaState(), "showBackground"); 310 } 311 312 lua_pushfstring(this->scriptModule_->getLuaState(), "mainmenu.lua"); 313 lua_setglobal(this->scriptModule_->getLuaState(), "filename"); 314 315 this->scriptModule_->executeScriptGlobal("showGUI"); 316 317 InputManager::getInstance().requestEnterState("gui"); 318 319 this->state_ = OnDisplay; 195 this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")"); 320 196 } 321 197 catch (CEGUI::Exception& ex) … … 332 208 COUT(2) << "Warning: GUI Manager not yet initialised, cannot load a GUI" << std::endl; 333 209 } 334 }335 336 /*void GUIManager::testFct()337 {338 //COUT(0) << "**** " << currentSceneManager_ << std::endl;339 this->showGUI("IngameMenu", currentSceneManager_);340 }341 342 void GUIManager::testOutput(const std::string& str)343 {344 COUT(0) << "***" << str << "***" << std::endl;345 }*/346 347 void GUIManager::hideGUI()348 {349 if (this->state_ != OnDisplay)350 return;351 //this->viewport_->setCamera(0);352 // has no effect since you cannot assign 0 as SceneManager353 //this->guiRenderer_->setTargetSceneManager(0);354 this->state_ = Ready;355 InputManager::getInstance().requestLeaveState("gui");356 210 } 357 211 -
code/branches/gui/src/orxonox/gui/GUIManager.h
r2840 r2850 40 40 #include <CEGUIInputEvent.h> 41 41 #include <CEGUISystem.h> 42 #include "core/Clock.h"43 42 #include "core/input/InputInterfaces.h" 44 43 … … 71 70 72 71 bool initialise(Ogre::RenderWindow* renderWindow); 73 void loadScene(const std::string& name);74 void update(const Clock& time)75 {76 assert(guiSystem_);77 guiSystem_->injectTimePulse(time.getDeltaTime());78 }79 void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export80 void hideGUI(); // tolua_export81 //void testOutput(const std::string& str); // tolua_export82 72 83 static void toggleGUI(); 73 void update(const Clock& time); 74 75 void showGUI(const std::string& name); 76 void executeCode(const std::string& str); 84 77 85 78 void setCamera(Ogre::Camera* camera); 86 Ogre::Camera* getCamera() { return this->backgroundCamera_; }87 88 static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)89 {90 getInstance().showGUI(name, sceneManager);91 }92 93 // please remove94 //void testFct();95 79 96 80 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export … … 99 83 private: 100 84 GUIManager(const GUIManager& instance); 85 86 void loadLuaCode(); 101 87 102 88 void keyPressed (const KeyEvent& evt) … … 120 106 void updateMouse(float dt) { } 121 107 122 void loadScenes();123 124 //Ogre::SceneManager* emptySceneManager_;125 Ogre::SceneManager* backgroundSceneManager_;126 //Ogre::Camera* emptyCamera_;127 Ogre::Camera* backgroundCamera_;128 //Ogre::Viewport* viewport_;129 108 Ogre::RenderWindow* renderWindow_; 130 109 CEGUI::OgreCEGUIRenderer* guiRenderer_; … … 135 114 CEGUI::Imageset* backgroundImage_; 136 115 lua_State* luaState_; 137 Ogre::SceneManager* currentSceneManager_;138 116 139 117 State state_;
Note: See TracChangeset
for help on using the changeset viewer.