Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2805 for code


Ignore:
Timestamp:
Mar 19, 2009, 4:59:30 PM (16 years ago)
Author:
rgrieder
Message:

Added new class: Game
It represents basic operation related to the running game like start and stop or managing the new GameStates.
And since only three lines were left in Main.cc I thought I could move that to the very beginning of 'Game'.

Location:
code/branches/gui/src
Files:
2 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/Clock.h

    r2171 r2805  
    4545    class _CoreExport Clock
    4646    {
    47         friend class RootGameState;
    48 
    4947    public:
    5048        Clock();
    5149        ~Clock();
     50
     51        void capture();
    5252
    5353        unsigned long long getMicroseconds()   const { return tickTime_; }
     
    6363    private:
    6464        Clock(const Clock& instance);
    65         void capture();
    6665
    6766        Ogre::Timer*       timer_;
  • code/branches/gui/src/core/GameState.h

    r1755 r2805  
    6565        template <class ParentType>
    6666        friend class GameState;
     67        // Hack
     68        friend class Game;
    6769
    6870    public:
  • code/branches/gui/src/core/RootGameState.cc

    r2710 r2805  
    3232#include "util/Exception.h"
    3333#include "Clock.h"
    34 #include "CommandLine.h"
    3534
    3635namespace orxonox
    3736{
    38     SetCommandLineArgument(state, "gui").shortcut("s");
    39 
    4037    RootGameState::RootGameState(const std::string& name)
    4138        : GameState<GameStateBase>(name)
     
    119116        this->stateRequest_ = name;
    120117    }
    121 
    122     /**
    123     @brief
    124         Main loop of the orxonox game.
    125         Starts the game. The little 'while' denotes the main loop.
    126         Whenever the root state is selected, the game ends.
    127     @param name
    128         State to start with (usually main menu or specified by command line)
    129     @note
    130         We use the Ogre::Timer to measure time since it uses the most precise
    131         method an a platform (however the windows timer lacks time when under
    132         heavy kernel load!).
    133     */
    134     void RootGameState::start()
    135     {
    136         // Don't catch errors when having a debugger in msvc
    137 #if !defined(ORXONOX_COMPILER_MSVC) || defined(NDEBUG)
    138         try
    139         {
    140 #endif
    141             // start global orxonox time
    142             Clock clock;
    143 
    144             this->activate();
    145 
    146             // get initial state from command line
    147             gotoState(CommandLine::getValue("state"));
    148 
    149             while (this->activeChild_)
    150             {
    151                 clock.capture();
    152 
    153                 this->tick(clock);
    154 
    155                 if (this->stateRequest_ != "")
    156                     gotoState(stateRequest_);
    157             }
    158 
    159             this->deactivate();
    160 #if !defined(ORXONOX_COMPILER_MSVC) || defined(NDEBUG)
    161         }
    162         // Note: These are all unhandled exceptions that should not have made its way here!
    163         // almost complete game catch block to display the messages appropriately.
    164         catch (std::exception& ex)
    165         {
    166             COUT(0) << ex.what() << std::endl;
    167             COUT(0) << "Program aborted." << std::endl;
    168             abort();
    169         }
    170         // anything that doesn't inherit from std::exception
    171         catch (...)
    172         {
    173             COUT(0) << "An unidentifiable exception has occured. Program aborted." << std::endl;
    174             abort();
    175         }
    176 #endif
    177     }
    178118}
  • code/branches/gui/src/core/RootGameState.h

    r2662 r2805  
    3737    class _CoreExport RootGameState : public GameState<GameStateBase>
    3838    {
     39        // Hack!
     40        friend class Game;
     41
    3942    public:
    4043        RootGameState(const std::string& name);
     
    4245
    4346        void requestState(const std::string& name);
    44         void start();
    4547
    4648    private:
  • code/branches/gui/src/orxonox/CMakeLists.txt

    r2801 r2805  
    2020SET_SOURCE_FILES(ORXONOX_SRC_FILES
    2121  CameraManager.cc
     22  Game.cc
    2223  GraphicsManager.cc
    2324  LevelManager.cc
    24   Main.cc
    2525  PawnManager.cc
    2626  PlayerManager.cc
  • code/branches/gui/src/orxonox/GraphicsManager.h

    r2801 r2805  
    3434 */
    3535
    36 #ifndef _GraphicsEngine_H__
    37 #define _GraphicsEngine_H__
     36#ifndef _GraphicsManager_H__
     37#define _GraphicsManager_H__
    3838
    3939#include "OrxonoxPrereqs.h"
     
    131131}
    132132
    133 #endif /* _GraphicsEngine_H__ */
     133#endif /* _GraphicsManager_H__ */
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.cc

    r2801 r2805  
    7575        Core::setShowsGraphics(true);
    7676
    77         // initialise graphics engine. Doesn't load the render window yet!
     77        // initialise graphics manager. Doesn't load the render window yet!
    7878        this->graphicsManager_ = new GraphicsManager();
    7979        this->graphicsManager_->initialise();
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r2800 r2805  
    8080        {
    8181            // add console commands
    82             FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
    83             functor->setObject(this);
    84             this->ccExit_ = createConsoleCommand(functor, "exit");
    85             CommandExecutor::addConsoleCommandShortcut(this->ccExit_);
    86         }
    87 
    88         {
    89             // add console commands
    9082            FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
    9183            functor->setObject(this);
     
    114106    {
    115107        // destroy console commands
    116         delete this->ccExit_;
    117108        delete this->ccSelectGameState_;
    118109
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r2799 r2805  
    5353        ~GSRoot();
    5454
    55         void exitGame()
    56         { requestState("root"); }
    57 
    5855        // this has to be public because proteced triggers a bug in msvc
    5956        // when taking the function address.
     
    9390
    9491        // console commands
    95         ConsoleCommand*       ccExit_;
    9692        ConsoleCommand*       ccSelectGameState_;
    9793        ConsoleCommand*       ccSetTimeFactor_;
Note: See TracChangeset for help on using the changeset viewer.