Changeset 1182 for code/branches/input/src/orxonox
- Timestamp:
- Apr 24, 2008, 9:40:23 PM (17 years ago)
- Location:
- code/branches/input/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/orxonox/Orxonox.cc
r1156 r1182 84 84 namespace orxonox 85 85 { 86 ConsoleCommand (Orxonox, exit, AccessLevel::None, true);87 ConsoleCommand (Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0);88 ConsoleCommand (Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0);89 86 ConsoleCommandShortcut(Orxonox, exit, AccessLevel::None); 87 ConsoleCommandShortcut(Orxonox, slomo, AccessLevel::Offline).setDefaultValue(0, 1.0); 88 ConsoleCommandShortcut(Orxonox, setTimeFactor, AccessLevel::Offline).setDefaultValue(0, 1.0); 89 ConsoleCommandShortcut(Orxonox, activateConsole, AccessLevel::None); 90 90 class Testconsole : public InputBufferListener 91 91 { … … 118 118 void exit() const 119 119 { 120 CommandExecutor::execute("setInputMode 2");120 InputManager::setInputState(InputManager::IS_NORMAL); 121 121 } 122 122 … … 177 177 delete this->orxonoxHUD_; 178 178 Loader::close(); 179 InputManager:: getSingleton().destroy();179 InputManager::destroy(); 180 180 if (this->auMan_) 181 181 delete this->auMan_; … … 392 392 void Orxonox::setupInputSystem() 393 393 { 394 inputHandler_ = &InputManager::getSingleton(); 395 if (!inputHandler_->initialise(ogre_->getWindowHandle(), 394 if (!InputManager::initialise(ogre_->getWindowHandle(), 396 395 ogre_->getWindowWidth(), ogre_->getWindowHeight())) 397 396 abortImmediateForce(); 398 inputHandler_->setInputMode(IM_INGAME);397 InputManager::setInputState(InputManager::IS_NORMAL); 399 398 } 400 399 … … 415 414 void Orxonox::startRenderLoop() 416 415 { 417 InputBuffer* ib = new InputBuffer(); 418 InputManager::getSingleton().feedInputBuffer(ib); 419 Testconsole* console = new Testconsole(ib); 420 ib->registerListener(console, &Testconsole::listen, true); 421 ib->registerListener(console, &Testconsole::execute, '\r', false); 422 ib->registerListener(console, &Testconsole::execute, '\n', false); 423 ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true); 424 ib->registerListener(console, &Testconsole::clear, '§', true); 425 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 426 ib->registerListener(console, &Testconsole::exit, (char)0x1B, true); 416 InputBuffer* ib = dynamic_cast<InputBuffer*>(InputManager::getKeyListener("buffer")); 417 console_ = new Testconsole(ib); 418 ib->registerListener(console_, &Testconsole::listen, true); 419 ib->registerListener(console_, &Testconsole::execute, '\r', false); 420 ib->registerListener(console_, &Testconsole::execute, '\n', false); 421 ib->registerListener(console_, &Testconsole::hintandcomplete, '\t', true); 422 ib->registerListener(console_, &Testconsole::clear, '§', true); 423 ib->registerListener(console_, &Testconsole::removeLast, '\b', true); 424 ib->registerListener(console_, &Testconsole::exit, (char)0x1B, true); 427 425 428 426 // first check whether ogre root object has been created … … 442 440 eventTimes[i].clear(); 443 441 // fill the fps time list with zeros 444 for (int i = 0; i < 20; i++)442 for (int i = 0; i < 50; i++) 445 443 eventTimes[3].push_back(0); 446 444 … … 468 466 // show the current time in the HUD 469 467 orxonoxHUD_->setTime((int)now, 0); 468 orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber()); 470 469 if (eventTimes[3].back() - eventTimes[3].front() != 0) 471 orxonoxHUD_->setRocket1((int)( 20000.0f/(eventTimes[3].back() - eventTimes[3].front())));470 orxonoxHUD_->setRocket1((int)(50000.0f/(eventTimes[3].back() - eventTimes[3].front()))); 472 471 473 472 // Iterate through all Tickables and call their tick(dt) function … … 533 532 } 534 533 535 /** 536 @brief Test method for the InputHandler. 537 But: Is actually responsible for catching an exit event.. 538 */ 539 void Orxonox::eventOccured(InputEvent &evt) 540 { 541 if (evt.id == 1) 542 this->abortRequest(); 534 void Orxonox::activateConsole() 535 { 536 InputManager::setInputState(InputManager::IS_CONSOLE); 543 537 } 544 538 } -
code/branches/input/src/orxonox/Orxonox.h
r1089 r1182 49 49 namespace orxonox { 50 50 51 class Testconsole; 52 51 53 enum gameMode{ 52 54 SERVER, … … 56 58 57 59 //! Orxonox singleton class 58 class _OrxonoxExport Orxonox : public InputEventListener60 class _OrxonoxExport Orxonox 59 61 { 60 62 public: … … 72 74 static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; } 73 75 static inline void exit() { Orxonox::getSingleton()->abortRequest(); } 76 static inline void activateConsole(); 74 77 75 78 private: … … 95 98 float calculateEventTime(unsigned long, std::deque<unsigned long>&); 96 99 97 void eventOccured(InputEvent &evt);98 99 100 private: 100 101 GraphicsEngine* ogre_; //!< our dearest graphics engine <3 … … 102 103 audio::AudioManager* auMan_; //!< audio manager 103 104 InputManager* inputHandler_; //!< Handles input with key bindings 105 Testconsole* console_; 104 106 Ogre::Timer* timer_; //!< Main loop timer 105 107 // TODO: make this a config-value by creating a config class for orxonox -
code/branches/input/src/orxonox/objects/SpaceShip.cc
r1064 r1182 428 428 void SpaceShip::tick(float dt) 429 429 { 430 if (InputManager::get Singleton().getMouse()->getEventCallback() != this)431 { 432 if (InputManager::get Singleton().getMouse())430 if (InputManager::getMouse()->getEventCallback() != this) 431 { 432 if (InputManager::getMouse()) 433 433 { 434 InputManager::get Singleton().getMouse()->setEventCallback(this);434 InputManager::getMouse()->setEventCallback(this); 435 435 this->setMouseEventCallback_ = true; 436 436 } … … 457 457 } 458 458 459 OIS::Keyboard* mKeyboard = InputManager::get Singleton().getKeyboard();459 OIS::Keyboard* mKeyboard = InputManager::getKeyboard(); 460 460 //FIXME: variable never used 461 461 //OIS::Mouse* mMouse = InputManager::getSingleton().getMouse();
Note: See TracChangeset
for help on using the changeset viewer.