Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1136 for code/branches/console


Ignore:
Timestamp:
Apr 22, 2008, 8:02:36 PM (17 years ago)
Author:
FelixSchulthess
Message:

created InGameConsole

Location:
code/branches/console/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/InputHandler.cc

    r1066 r1136  
    8585      InputHandlerGame::callListeners(e);
    8686    }
    87     else if (e.key == OIS::KC_NUMPADENTER)
     87    else if (e.key == OIS::KC_UNASSIGNED || e.key == OIS::KC_NUMPADENTER)
    8888    {
    8989      InputManager::getSingleton().setInputMode(IM_KEYBOARD);
  • code/branches/console/src/orxonox/CMakeLists.txt

    r1070 r1136  
    33  Main.cc
    44  Orxonox.cc
     5  console/InGameConsole.cc
    56#  SpaceshipSteering.cc
    67  hud/HUD.cc
  • code/branches/console/src/orxonox/Orxonox.cc

    r1133 r1136  
    5454//#include "util/Sleep.h"
    5555#include "util/ArgReader.h"
    56 #include "util/ExprParser.h"
    5756
    5857// core
     
    7675#include "tools/Timer.h"
    7776#include "hud/HUD.h"
     77#include "console/InGameConsole.h"
     78//#include "objects/weapon/BulletManager.h"
    7879
    7980// FIXME: is this really file scope?
     
    125126  };
    126127
    127   class Calculator
    128   {
    129   public:
    130     static void calculate(const std::string& calculation)
    131     {
    132       ExprParser expr(calculation);
    133       if (expr.getSuccess())
    134       {
    135         if (expr.getResult() == 42.0)
    136           std::cout << "Greetings from the restaurant at the end of the universe." << std::endl;
    137         // FIXME: insert modifier to display in full precision
    138         std::cout << "Result is: " << expr.getResult() << std::endl;
    139         if (expr.getRemains() != "")
    140           std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
    141               << expr.getRemains() << "'" << std::endl;
    142       }
    143       else
    144         std::cout << "Cannot calculate expression: Parse error" << std::endl;
    145     }
    146   };
    147   ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);
    148 
    149128  /**
    150129    @brief Reference to the only instance of the class.
     
    162141    this->auMan_ = 0;
    163142    this->inputHandler_ = 0;
     143    //this->root_ = 0;
    164144    // turn on frame smoothing by setting a value different from 0
    165145    this->frameSmoothingTime_ = 0.0f;
     
    174154  {
    175155    // keep in mind: the order of deletion is very important!
     156//    if (this->bulletMgr_)
     157//      delete this->bulletMgr_;
    176158    if (this->orxonoxHUD_)
    177159      delete this->orxonoxHUD_;
     
    191173
    192174  /**
    193     @brief Immediately deletes the orxonox object.
    194     Never use if you can help it while rendering!
    195   */
    196   void Orxonox::abortImmediateForce()
    197   {
    198     COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl;
     175   * error kills orxonox
     176   */
     177  void Orxonox::abortImmediate(/* some error code */)
     178  {
     179    //TODO: destroy and destruct everything and print nice error msg
    199180    delete this;
    200181  }
     
    205186  void Orxonox::abortRequest()
    206187  {
    207     COUT(3) << "*** Orxonox: Abort requested." << std::endl;
    208188    bAbort_ = true;
    209189  }
     
    246226    ar.checkArgument("data", this->dataPath_, false);
    247227    ar.checkArgument("ip", serverIp_, false);
    248     if(ar.errorHandling()) abortImmediateForce();
     228    if(ar.errorHandling()) abortImmediate();
    249229    if(mode == std::string("client"))
    250230    {
     
    269249    ogre_->setup();
    270250    //root_ = ogre_->getRoot();
    271     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     251    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    272252
    273253    server_g = new network::Server();
     
    284264    else
    285265      client_g = new network::Client(serverIp_, NETWORK_PORT);
    286     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     266    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    287267  }
    288268
     
    293273    ogre_->setConfigPath(path);
    294274    ogre_->setup();
    295     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     275    //root_ = ogre_->getRoot();
     276    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    296277  }
    297278
     
    321302    auMan_ = new audio::AudioManager();
    322303
     304    //bulletMgr_ = new BulletManager();
     305
    323306    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    324307    HUD* orxonoxHud;
     
    368351    auMan_ = new audio::AudioManager();
    369352
     353    //bulletMgr_ = new BulletManager();
     354
    370355    // load this file from config
    371356    Level* startlevel = new Level("levels/sample.oxw");
     
    396381    if (!inputHandler_->initialise(ogre_->getWindowHandle(),
    397382          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
    398       abortImmediateForce();
     383      abortImmediate();
    399384    inputHandler_->setInputMode(IM_INGAME);
    400385  }
     
    418403    InputBuffer* ib = new InputBuffer();
    419404    InputManager::getSingleton().feedInputBuffer(ib);
     405    /*
    420406    Testconsole* console = new Testconsole(ib);
    421407    ib->registerListener(console, &Testconsole::listen, true);
     
    426412    ib->registerListener(console, &Testconsole::removeLast, '\b', true);
    427413    ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
     414    */
     415
     416    orxonoxConsole_ = new InGameConsole(ib);
     417    ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
     418    ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\r', false);
     419    ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\n', false);
     420    ib->registerListener(orxonoxConsole_, &InGameConsole::hintandcomplete, '\t', true);
     421    ib->registerListener(orxonoxConsole_, &InGameConsole::clear, '§', true);
     422    ib->registerListener(orxonoxConsole_, &InGameConsole::removeLast, '\b', true);
     423    ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true);
    428424
    429425    // first check whether ogre root object has been created
    430426    if (Ogre::Root::getSingletonPtr() == 0)
    431427    {
    432       COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
     428      COUT(2) << "Error: Could not start rendering. No Ogre root object found" << std::endl;
    433429      return;
    434430    }
    435     Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
    436 
    437431
    438432    // Contains the times of recently fired events
     
    454448          {
    455449                  // Pump messages in all registered RenderWindows
    456       // This calls the WindowEventListener objects.
    457450      Ogre::WindowEventUtilities::messagePump();
    458451
     
    473466
    474467      // Iterate through all Tickables and call their tick(dt) function
    475       for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    476         it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     468      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
     469      {
     470        (it)->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     471        it++;
     472      }
    477473
    478474      // don't forget to call _fireFrameStarted in ogre to make sure
    479475      // everything goes smoothly
    480       ogreRoot._fireFrameStarted(evt);
     476      Ogre::Root::getSingleton()._fireFrameStarted(evt);
    481477
    482478      // server still renders at the moment
    483479      //if (mode_ != SERVER)
    484       ogreRoot._updateAllRenderTargets(); // only render in non-server mode
     480      Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode
    485481
    486482      // get current time
     
    492488
    493489      // again, just to be sure ogre works fine
    494       ogreRoot._fireFrameEnded(evt);
     490      Ogre::Root::getSingleton()._fireFrameEnded(evt);
    495491          }
    496492  }
  • code/branches/console/src/orxonox/Orxonox.h

    r1089 r1136  
    6161      void init(int argc, char **argv, std::string path);
    6262      void start();
    63       void abortImmediateForce();
     63      // not sure if this should be private
     64      void abortImmediate(/* some error code */);
    6465      void abortRequest();
    6566      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
     
    106107      float                 frameSmoothingTime_;
    107108      HUD*                  orxonoxHUD_;
     109      InGameConsole*        orxonoxConsole_;
    108110      bool                  bAbort_;        //!< aborts the render loop if true
    109111      float                 timefactor_;    //!< A factor to change the gamespeed
  • code/branches/console/src/orxonox/OrxonoxPrereqs.h

    r1056 r1136  
    9696  // hud
    9797  class HUD;
     98  //console
     99  class InGameConsole;
    98100}
    99101
Note: See TracChangeset for help on using the changeset viewer.