[Orxonox-commit 166] r2845 - in branches/gui/src: core orxonox orxonox/gamestates
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Mar 25 17:33:58 CET 2009
Author: rgrieder
Date: 2009-03-25 16:33:58 +0000 (Wed, 25 Mar 2009)
New Revision: 2845
Modified:
branches/gui/src/core/Game.cc
branches/gui/src/orxonox/Main.cc
branches/gui/src/orxonox/gamestates/GSGUI.cc
branches/gui/src/orxonox/gamestates/GSRoot.cc
Log:
- Moved some code from Game to Main and GSRoot
- Renamed "gui" GameState to "mainMenu"
Modified: branches/gui/src/core/Game.cc
===================================================================
--- branches/gui/src/core/Game.cc 2009-03-25 16:23:00 UTC (rev 2844)
+++ branches/gui/src/core/Game.cc 2009-03-25 16:33:58 UTC (rev 2845)
@@ -49,10 +49,9 @@
namespace orxonox
{
- void stop_game()
- {
- Game::getInstance().stop();
- }
+ static void stop_game()
+ { Game::getInstance().stop(); }
+ SetConsoleCommandShortcutExternAlias(stop_game, "exit");
struct _CoreExport GameStateTreeNode
{
@@ -61,10 +60,6 @@
std::vector<GameStateTreeNode*> children_;
};
- SetCommandLineArgument(state, "gui").shortcut("s");
- SetCommandLineSwitch(startWithConsole);
- SetConsoleCommandShortcutExternAlias(stop_game, "exit");
-
std::map<std::string, GameState*> Game::allStates_s;
Game* Game::singletonRef_s = 0;
@@ -131,43 +126,12 @@
*/
void Game::run()
{
- // </EXPORT THIS>
- this->setStateHierarchy(
- "root"
- " graphics"
- " gui"
- " standalone"
- " level"
- " server"
- " level"
- " client"
- " level"
- " dedicated"
- " level"
- " ioConsole"
- );
- // </EXPORT THIS>
-
-
- // Always start with the root state
+ // Always start with the ROOT state
this->requestedStateNodes_.push_back(this->rootStateNode_);
this->activeStateNode_ = this->rootStateNode_;
this->loadState(this->rootStateNode_->state_);
- // <EXPORT THIS>
- if (CommandLine::getValue("startWithConsole").getBool())
- {
- // Start the game in the console
- this->requestState("ioConsole");
- }
- else
- {
- // Start in GUI main menu
- this->requestState("graphics");
- this->requestState("gui");
- }
- // </EXPORT THIS>
-
+ // START GAME
this->gameClock_->capture(); // first delta time should be about 0 seconds
while (!this->abort_ && !this->activeStates_.empty())
{
@@ -223,7 +187,7 @@
}
}
- // Unload all remaining states
+ // UNLOAD all remaining states
while (!this->activeStates_.empty())
this->unloadState(this->activeStates_.back());
this->activeStateNode_ = 0;
Modified: branches/gui/src/orxonox/Main.cc
===================================================================
--- branches/gui/src/orxonox/Main.cc 2009-03-25 16:23:00 UTC (rev 2844)
+++ branches/gui/src/orxonox/Main.cc 2009-03-25 16:33:58 UTC (rev 2845)
@@ -47,6 +47,22 @@
{
{
orxonox::Game orxonox(argc, argv);
+
+ orxonox.setStateHierarchy(
+ "root"
+ " graphics"
+ " mainMenu"
+ " standalone"
+ " level"
+ " server"
+ " level"
+ " client"
+ " level"
+ " dedicated"
+ " level"
+ " ioConsole"
+ );
+
orxonox.run();
} // orxonox gets destroyed right here!
Modified: branches/gui/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSGUI.cc 2009-03-25 16:23:00 UTC (rev 2844)
+++ branches/gui/src/orxonox/gamestates/GSGUI.cc 2009-03-25 16:33:58 UTC (rev 2845)
@@ -40,7 +40,7 @@
namespace orxonox
{
- AddGameState(GSGUI, "gui");
+ AddGameState(GSGUI, "mainMenu");
GSGUI::GSGUI(const std::string& name)
: GameState(name)
Modified: branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- branches/gui/src/orxonox/gamestates/GSRoot.cc 2009-03-25 16:23:00 UTC (rev 2844)
+++ branches/gui/src/orxonox/gamestates/GSRoot.cc 2009-03-25 16:33:58 UTC (rev 2845)
@@ -33,6 +33,7 @@
#include "util/Debug.h"
#include "core/Clock.h"
#include "core/Core.h"
+#include "core/CommandLine.h"
#include "core/ConsoleCommand.h"
#include "tools/TimeFactorListener.h"
#include "tools/Timer.h"
@@ -42,6 +43,7 @@
namespace orxonox
{
AddGameState(GSRoot, "root");
+ SetCommandLineSwitch(startWithConsole);
GSRoot::GSRoot(const std::string& name)
: GameState(name)
@@ -77,6 +79,20 @@
this->ccPause_ = createConsoleCommand(functor, "pause");
CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
}
+
+ // Determine where to start
+ if (CommandLine::getValue("startWithConsole").getBool())
+ {
+ // Start the game in the console
+ Game::getInstance().requestState("ioConsole");
+ }
+ else
+ {
+ // Start in GUI main menu
+ Game::getInstance().requestState("graphics");
+ Game::getInstance().requestState("mainMenu");
+ }
+
}
void GSRoot::deactivate()
More information about the Orxonox-commit
mailing list