Changeset 2896 for code/trunk/src/orxonox/gamestates/GSLevel.cc
- Timestamp:
- Apr 6, 2009, 1:59:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gui merged: 2796,2798-2801,2805,2807-2808,2811,2814-2817,2834,2840-2850,2853-2854,2859,2862-2863,2869,2875,2887,2892
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gamestates/GSLevel.cc
r2826 r2896 24 24 * Co-authors: 25 25 * Fabian 'x3n' Landau 26 * Benjamin Knecht 26 27 * 27 28 */ … … 39 40 #include "core/CommandLine.h" 40 41 #include "core/ConfigValueIncludes.h" 42 #include "core/Core.h" 41 43 #include "core/CoreIncludes.h" 42 #include "core/Core.h" 44 #include "core/Game.h" 45 #include "core/GameMode.h" 43 46 #include "objects/Tickable.h" 44 47 #include "objects/Radar.h" 45 48 #include "CameraManager.h" 49 #include "GraphicsManager.h" 46 50 #include "LevelManager.h" 47 51 #include "PlayerManager.h" 52 #include "gui/GUIManager.h" 48 53 49 54 namespace orxonox 50 55 { 56 AddGameState(GSLevel, "level"); 57 51 58 SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l"); 52 53 GSLevel::GSLevel() 54 // : GameState<GSGraphics>(name) 55 : keyBinder_(0) 56 , inputState_(0) 59 SetConsoleCommand(GSLevel, showIngameGUI, true); 60 61 GSLevel::GSLevel(const std::string& name) 62 : GameState(name) 63 , keyBinder_(0) 64 , gameInputState_(0) 65 , guiMouseOnlyInputState_(0) 66 , guiKeysOnlyInputState_(0) 57 67 , radar_(0) 58 68 , startFile_(0) … … 64 74 this->ccKeybind_ = 0; 65 75 this->ccTkeybind_ = 0; 66 76 } 77 78 GSLevel::~GSLevel() 79 { 80 } 81 82 void GSLevel::setConfigValues() 83 { 84 SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName="); 85 } 86 87 void GSLevel::activate() 88 { 67 89 setConfigValues(); 68 } 69 70 GSLevel::~GSLevel() 71 { 72 } 73 74 void GSLevel::setConfigValues() 75 { 76 SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName="); 77 } 78 79 void GSLevel::enter(Ogre::Viewport* viewport) 80 { 81 if (Core::showsGraphics()) 82 { 83 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 90 91 if (GameMode::showsGraphics()) 92 { 93 gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game"); 84 94 keyBinder_ = new KeyBinder(); 85 95 keyBinder_->loadBindings("keybindings.ini"); 86 inputState_->setHandler(keyBinder_); 96 gameInputState_->setHandler(keyBinder_); 97 98 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly"); 99 guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr()); 100 101 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly"); 102 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 87 103 88 104 // create the global CameraManager 89 assert(viewport); 90 this->cameraManager_ = new CameraManager(viewport); 105 this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport()); 91 106 92 107 // Start the Radar … … 96 111 this->playerManager_ = new PlayerManager(); 97 112 98 if ( Core::isMaster())113 if (GameMode::isMaster()) 99 114 { 100 115 // create the global LevelManager … … 104 119 } 105 120 106 if (Core::showsGraphics()) 107 { 108 // TODO: insert slomo console command with 109 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 110 121 if (GameMode::showsGraphics()) 122 { 111 123 // keybind console command 112 124 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); … … 126 138 } 127 139 128 void GSLevel::leave() 140 void GSLevel::showIngameGUI(bool show) 141 { 142 if (show) 143 { 144 GUIManager::getInstancePtr()->showGUI("inGameTest"); 145 GUIManager::getInstancePtr()->executeCode("showCursor()"); 146 InputManager::getInstance().requestEnterState("guiMouseOnly"); 147 } 148 else 149 { 150 GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")"); 151 GUIManager::getInstancePtr()->executeCode("hideCursor()"); 152 InputManager::getInstance().requestLeaveState("guiMouseOnly"); 153 } 154 } 155 156 void GSLevel::deactivate() 129 157 { 130 158 // destroy console commands … … 139 167 this->ccTkeybind_ = 0; 140 168 } 169 141 170 142 171 // this call will delete every BaseObject! … … 146 175 //Loader::close(); 147 176 148 if ( Core::showsGraphics())177 if (GameMode::showsGraphics()) 149 178 InputManager::getInstance().requestLeaveState("game"); 150 179 151 if ( Core::isMaster())180 if (GameMode::isMaster()) 152 181 this->unloadLevel(); 153 182 … … 176 205 } 177 206 178 if (Core::showsGraphics()) 179 { 180 inputState_->setHandler(0); 207 if (GameMode::showsGraphics()) 208 { 209 gameInputState_->setHandler(0); 210 guiMouseOnlyInputState_->setHandler(0); 211 guiKeysOnlyInputState_->setHandler(0); 181 212 InputManager::getInstance().requestDestroyState("game"); 182 213 if (this->keyBinder_) … … 188 219 } 189 220 190 void GSLevel:: ticked(const Clock& time)191 { 192 // Commented by 1337: Temporarily moved to GSGraphics.221 void GSLevel::update(const Clock& time) 222 { 223 // Note: Temporarily moved to GSGraphics. 193 224 //// Call the scene objects 194 225 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) … … 233 264 Command string that can be executed by the CommandExecutor 234 265 OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify 235 the key/button/axis that has been activated. This is configured above in enter().266 the key/button/axis that has been activated. This is configured above in activate(). 236 267 */ 237 268 void GSLevel::keybindInternal(const std::string& command, bool bTemporary) 238 269 { 239 if ( Core::showsGraphics())270 if (GameMode::showsGraphics()) 240 271 { 241 272 static std::string bindingString = "";
Note: See TracChangeset
for help on using the changeset viewer.