Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 3:42:49 AM (16 years ago)
Author:
landauf
Message:

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Orxonox.cc

    r1039 r1052  
    5555
    5656// core
     57#include "core/ConsoleCommand.h"
    5758#include "core/Debug.h"
    5859#include "core/Factory.h"
    5960#include "core/Loader.h"
    6061#include "core/Tickable.h"
     62#include "core/InputBuffer.h"
    6163#include "core/InputManager.h"
    6264
     
    8082namespace orxonox
    8183{
     84  ConsoleCommand(Orxonox, exit, AccessLevel::None, true);
     85  ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0);
     86  ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0);
     87
     88  class Testconsole : public InputBufferListener
     89  {
     90    public:
     91      Testconsole(InputBuffer* ib) : ib_(ib) {}
     92      void listen() const
     93      {
     94        std::cout << "> " << this->ib_->get() << std::endl;
     95      }
     96      void execute() const
     97      {
     98        std::cout << ">> " << this->ib_->get() << std::endl;
     99        if (!CommandExecutor::execute(this->ib_->get()))
     100          std::cout << "Error" << std::endl;
     101        this->ib_->clear();
     102      }
     103      void hintandcomplete() const
     104      {
     105        std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
     106        this->ib_->set(CommandExecutor::complete(this->ib_->get()));
     107      }
     108      void clear() const
     109      {
     110        this->ib_->clear();
     111      }
     112      void removeLast() const
     113      {
     114        this->ib_->removeLast();
     115      }
     116
     117    private:
     118      InputBuffer* ib_;
     119  };
     120
    82121  /**
    83122    @brief Reference to the only instance of the class.
     
    198237  {
    199238    COUT(2) << "initialising server" << std::endl;
    200    
     239
    201240    ogre_->setConfigPath(path);
    202241    ogre_->setup();
    203242    //root_ = ogre_->getRoot();
    204243    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    205    
     244
    206245    server_g = new network::Server();
    207246  }
     
    210249  {
    211250    COUT(2) << "initialising client" << std::endl;\
    212    
     251
    213252    ogre_->setConfigPath(path);
    214253    ogre_->setup();
     
    219258    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    220259  }
    221  
     260
    222261  void Orxonox::standaloneInit(std::string path)
    223262  {
    224263    COUT(2) << "initialising standalone mode" << std::endl;
    225    
     264
    226265    ogre_->setConfigPath(path);
    227266    ogre_->setup();
     
    229268    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    230269  }
    231  
     270
    232271  /**
    233272   * start modules
     
    246285    }
    247286  }
    248  
     287
    249288  void Orxonox::clientStart(){
    250289    ogre_->initialise();
    251290    Factory::createClassHierarchy();
    252    
    253    
     291
     292
    254293    auMan_ = new audio::AudioManager();
    255294
    256295    //bulletMgr_ = new BulletManager();
    257    
     296
    258297    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    259298    HUD* orxonoxHud;
     
    262301    orxonoxHud->setEnergyDistr(20,20,60);
    263302    hudOverlay->show();
    264    
     303
    265304    client_g->establishConnection();
    266305    client_g->tick(0);
    267    
    268    
     306
     307
    269308    //setupInputSystem();
    270    
     309
    271310    startRenderLoop();
    272311  }
    273  
     312
    274313  void Orxonox::serverStart(){
    275314    //TODO: start modules
     
    279318    createScene();
    280319    setupInputSystem();
    281    
     320
    282321    server_g->open();
    283    
     322
    284323    startRenderLoop();
    285324  }
    286  
     325
    287326  void Orxonox::standaloneStart(){
    288327    //TODO: start modules
     
    292331    createScene();
    293332    setupInputSystem();
    294    
     333
    295334    startRenderLoop();
    296335  }
     
    351390  void Orxonox::startRenderLoop()
    352391  {
     392    InputBuffer* ib = new InputBuffer();
     393    Testconsole* console = new Testconsole(ib);
     394    ib->registerListener(console, &Testconsole::listen, true);
     395    ib->registerListener(console, &Testconsole::execute, '\r', false);
     396    ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true);
     397    ib->registerListener(console, &Testconsole::clear, '§', true);
     398    ib->registerListener(console, &Testconsole::removeLast, '\b', true);
     399
    353400    // first check whether ogre root object has been created
    354401    if (Ogre::Root::getSingletonPtr() == 0)
     
    395442      // Iterate through all Tickables and call their tick(dt) function
    396443      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
    397         (it++)->tick((float)evt.timeSinceLastFrame);
     444        (it++)->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    398445
    399446      // don't forget to call _fireFrameStarted in ogre to make sure
Note: See TracChangeset for help on using the changeset viewer.