Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 24, 2008, 9:40:23 PM (16 years ago)
Author:
rgrieder
Message:
  • InputManager works so far, but has to be largely extended
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/Orxonox.cc

    r1156 r1182  
    8484namespace orxonox
    8585{
    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);
    9090  class Testconsole : public InputBufferListener
    9191  {
     
    118118      void exit() const
    119119      {
    120         CommandExecutor::execute("setInputMode 2");
     120        InputManager::setInputState(InputManager::IS_NORMAL);
    121121      }
    122122
     
    177177      delete this->orxonoxHUD_;
    178178    Loader::close();
    179     InputManager::getSingleton().destroy();
     179    InputManager::destroy();
    180180    if (this->auMan_)
    181181      delete this->auMan_;
     
    392392  void Orxonox::setupInputSystem()
    393393  {
    394     inputHandler_ = &InputManager::getSingleton();
    395     if (!inputHandler_->initialise(ogre_->getWindowHandle(),
     394    if (!InputManager::initialise(ogre_->getWindowHandle(),
    396395          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
    397396      abortImmediateForce();
    398     inputHandler_->setInputMode(IM_INGAME);
     397    InputManager::setInputState(InputManager::IS_NORMAL);
    399398  }
    400399
     
    415414  void Orxonox::startRenderLoop()
    416415  {
    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);
    427425
    428426    // first check whether ogre root object has been created
     
    442440      eventTimes[i].clear();
    443441    // fill the fps time list with zeros
    444     for (int i = 0; i < 20; i++)
     442    for (int i = 0; i < 50; i++)
    445443      eventTimes[3].push_back(0);
    446444
     
    468466      // show the current time in the HUD
    469467      orxonoxHUD_->setTime((int)now, 0);
     468      orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber());
    470469      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())));
    472471
    473472      // Iterate through all Tickables and call their tick(dt) function
     
    533532  }
    534533
    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);
    543537  }
    544538}
Note: See TracChangeset for help on using the changeset viewer.