Changeset 1136 for code/branches/console
- Timestamp:
- Apr 22, 2008, 8:02:36 PM (17 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/InputHandler.cc
r1066 r1136 85 85 InputHandlerGame::callListeners(e); 86 86 } 87 else if (e.key == OIS::KC_ NUMPADENTER)87 else if (e.key == OIS::KC_UNASSIGNED || e.key == OIS::KC_NUMPADENTER) 88 88 { 89 89 InputManager::getSingleton().setInputMode(IM_KEYBOARD); -
code/branches/console/src/orxonox/CMakeLists.txt
r1070 r1136 3 3 Main.cc 4 4 Orxonox.cc 5 console/InGameConsole.cc 5 6 # SpaceshipSteering.cc 6 7 hud/HUD.cc -
code/branches/console/src/orxonox/Orxonox.cc
r1133 r1136 54 54 //#include "util/Sleep.h" 55 55 #include "util/ArgReader.h" 56 #include "util/ExprParser.h"57 56 58 57 // core … … 76 75 #include "tools/Timer.h" 77 76 #include "hud/HUD.h" 77 #include "console/InGameConsole.h" 78 //#include "objects/weapon/BulletManager.h" 78 79 79 80 // FIXME: is this really file scope? … … 125 126 }; 126 127 127 class Calculator128 {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 precision138 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 else144 std::cout << "Cannot calculate expression: Parse error" << std::endl;145 }146 };147 ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);148 149 128 /** 150 129 @brief Reference to the only instance of the class. … … 162 141 this->auMan_ = 0; 163 142 this->inputHandler_ = 0; 143 //this->root_ = 0; 164 144 // turn on frame smoothing by setting a value different from 0 165 145 this->frameSmoothingTime_ = 0.0f; … … 174 154 { 175 155 // keep in mind: the order of deletion is very important! 156 // if (this->bulletMgr_) 157 // delete this->bulletMgr_; 176 158 if (this->orxonoxHUD_) 177 159 delete this->orxonoxHUD_; … … 191 173 192 174 /** 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 199 180 delete this; 200 181 } … … 205 186 void Orxonox::abortRequest() 206 187 { 207 COUT(3) << "*** Orxonox: Abort requested." << std::endl;208 188 bAbort_ = true; 209 189 } … … 246 226 ar.checkArgument("data", this->dataPath_, false); 247 227 ar.checkArgument("ip", serverIp_, false); 248 if(ar.errorHandling()) abortImmediate Force();228 if(ar.errorHandling()) abortImmediate(); 249 229 if(mode == std::string("client")) 250 230 { … … 269 249 ogre_->setup(); 270 250 //root_ = ogre_->getRoot(); 271 if(!ogre_->load(this->dataPath_)) abortImmediate Force(/* unable to load */);251 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 272 252 273 253 server_g = new network::Server(); … … 284 264 else 285 265 client_g = new network::Client(serverIp_, NETWORK_PORT); 286 if(!ogre_->load(this->dataPath_)) abortImmediate Force(/* unable to load */);266 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 287 267 } 288 268 … … 293 273 ogre_->setConfigPath(path); 294 274 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 */); 296 277 } 297 278 … … 321 302 auMan_ = new audio::AudioManager(); 322 303 304 //bulletMgr_ = new BulletManager(); 305 323 306 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 324 307 HUD* orxonoxHud; … … 368 351 auMan_ = new audio::AudioManager(); 369 352 353 //bulletMgr_ = new BulletManager(); 354 370 355 // load this file from config 371 356 Level* startlevel = new Level("levels/sample.oxw"); … … 396 381 if (!inputHandler_->initialise(ogre_->getWindowHandle(), 397 382 ogre_->getWindowWidth(), ogre_->getWindowHeight())) 398 abortImmediate Force();383 abortImmediate(); 399 384 inputHandler_->setInputMode(IM_INGAME); 400 385 } … … 418 403 InputBuffer* ib = new InputBuffer(); 419 404 InputManager::getSingleton().feedInputBuffer(ib); 405 /* 420 406 Testconsole* console = new Testconsole(ib); 421 407 ib->registerListener(console, &Testconsole::listen, true); … … 426 412 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 427 413 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); 428 424 429 425 // first check whether ogre root object has been created 430 426 if (Ogre::Root::getSingletonPtr() == 0) 431 427 { 432 COUT(2) << " *** OrxonoxError: 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; 433 429 return; 434 430 } 435 Ogre::Root& ogreRoot = Ogre::Root::getSingleton();436 437 431 438 432 // Contains the times of recently fired events … … 454 448 { 455 449 // Pump messages in all registered RenderWindows 456 // This calls the WindowEventListener objects.457 450 Ogre::WindowEventUtilities::messagePump(); 458 451 … … 473 466 474 467 // 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 } 477 473 478 474 // don't forget to call _fireFrameStarted in ogre to make sure 479 475 // everything goes smoothly 480 ogreRoot._fireFrameStarted(evt);476 Ogre::Root::getSingleton()._fireFrameStarted(evt); 481 477 482 478 // server still renders at the moment 483 479 //if (mode_ != SERVER) 484 ogreRoot._updateAllRenderTargets(); // only render in non-server mode480 Ogre::Root::getSingleton()._updateAllRenderTargets(); // only render in non-server mode 485 481 486 482 // get current time … … 492 488 493 489 // again, just to be sure ogre works fine 494 ogreRoot._fireFrameEnded(evt);490 Ogre::Root::getSingleton()._fireFrameEnded(evt); 495 491 } 496 492 } -
code/branches/console/src/orxonox/Orxonox.h
r1089 r1136 61 61 void init(int argc, char **argv, std::string path); 62 62 void start(); 63 void abortImmediateForce(); 63 // not sure if this should be private 64 void abortImmediate(/* some error code */); 64 65 void abortRequest(); 65 66 inline audio::AudioManager* getAudioManagerPointer() { return auMan_; }; … … 106 107 float frameSmoothingTime_; 107 108 HUD* orxonoxHUD_; 109 InGameConsole* orxonoxConsole_; 108 110 bool bAbort_; //!< aborts the render loop if true 109 111 float timefactor_; //!< A factor to change the gamespeed -
code/branches/console/src/orxonox/OrxonoxPrereqs.h
r1056 r1136 96 96 // hud 97 97 class HUD; 98 //console 99 class InGameConsole; 98 100 } 99 101
Note: See TracChangeset
for help on using the changeset viewer.