Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 24, 2008, 9:40:23 PM (17 years ago)
Author:
rgrieder
Message:
  • InputManager works so far, but has to be largely extended
Location:
code/branches/input/src/orxonox
Files:
3 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}
  • code/branches/input/src/orxonox/Orxonox.h

    r1089 r1182  
    4949namespace orxonox {
    5050
     51  class Testconsole;
     52
    5153  enum gameMode{
    5254    SERVER,
     
    5658
    5759  //! Orxonox singleton class
    58   class _OrxonoxExport Orxonox : public InputEventListener
     60  class _OrxonoxExport Orxonox
    5961  {
    6062    public:
     
    7274      static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; }
    7375      static inline void exit() { Orxonox::getSingleton()->abortRequest(); }
     76      static inline void activateConsole();
    7477
    7578   private:
     
    9598      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
    9699
    97       void eventOccured(InputEvent &evt);
    98 
    99100    private:
    100101      GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
     
    102103      audio::AudioManager*  auMan_;         //!< audio manager
    103104      InputManager*         inputHandler_;  //!< Handles input with key bindings
     105      Testconsole*          console_;
    104106      Ogre::Timer*          timer_;         //!< Main loop timer
    105107      // TODO: make this a config-value by creating a config class for orxonox
  • code/branches/input/src/orxonox/objects/SpaceShip.cc

    r1064 r1182  
    428428    void SpaceShip::tick(float dt)
    429429    {
    430       if (InputManager::getSingleton().getMouse()->getEventCallback() != this)
    431         {
    432             if (InputManager::getSingleton().getMouse())
     430      if (InputManager::getMouse()->getEventCallback() != this)
     431        {
     432            if (InputManager::getMouse())
    433433            {
    434                 InputManager::getSingleton().getMouse()->setEventCallback(this);
     434                InputManager::getMouse()->setEventCallback(this);
    435435                this->setMouseEventCallback_ = true;
    436436            }
     
    457457        }
    458458
    459         OIS::Keyboard* mKeyboard = InputManager::getSingleton().getKeyboard();
     459        OIS::Keyboard* mKeyboard = InputManager::getKeyboard();
    460460        //FIXME: variable never used
    461461        //OIS::Mouse* mMouse = InputManager::getSingleton().getMouse();
Note: See TracChangeset for help on using the changeset viewer.