Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 6, 2009, 1:59:00 AM (15 years ago)
Author:
landauf
Message:

Merged gui branch back to trunk.

I did 2 small changes in IngameManager.cc on line 777 and 888 (yes, really), because const_reverse_iterator strangely doesn't work on MinGW.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/GameState.h

    r1755 r2896  
    3939
    4040#include <string>
    41 #include <vector>
    4241#include <map>
    43 #include <cassert>
    44 #include "Clock.h"
     42#include "CorePrereqs.h"
    4543
    4644namespace orxonox
     
    6058        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
    6159    */
    62     class _CoreExport GameStateBase
     60    class _CoreExport GameState
    6361    {
    64         friend class RootGameState;
    65         template <class ParentType>
    66         friend class GameState;
     62        friend class Game;
    6763
    6864    public:
     
    7167            Gives information about what the GameState is currently doing
    7268        */
    73         struct Operations
     69        struct State
    7470        {
    75             unsigned active    : 1;
    76             unsigned entering  : 1;
    77             unsigned leaving   : 1;
    78             unsigned running   : 1;
    79             unsigned suspended : 1;
     71            unsigned active       : 1;
     72            unsigned activating   : 1;
     73            unsigned deactivating : 1;
     74            unsigned updating     : 1;
     75            unsigned suspended    : 1;
     76            unsigned topState     : 1;
    8077        };
    8178
    8279    public:
    83         virtual ~GameStateBase();
     80        GameState(const std::string& name);
     81        virtual ~GameState();
    8482
    8583        const std::string& getName() const { return name_; }
    86         const Operations getOperation() const { return this->operation_; }
    87         bool isInSubtree(GameStateBase* state) const;
     84        State getActivity() const    { return this->activity_; }
     85        GameState* getParent() const       { return this->parent_; }
    8886
    89         GameStateBase* getState(const std::string& name);
    90         GameStateBase* getRoot();
    91         //! Returns the currently active game state
    92         virtual GameStateBase* getCurrentState();
    93 
    94         virtual void requestState(const std::string& name);
    95 
    96         void addChild(GameStateBase* state);
    97         void removeChild(GameStateBase* state);
    98         void removeChild(const std::string& name);
     87        void addChild(GameState* state);
     88        void removeChild(GameState* state);
    9989
    10090    protected:
    101         virtual void enter() = 0;
    102         virtual void leave() = 0;
    103         virtual void ticked(const Clock& time) = 0;
    104 
    105         GameStateBase* getActiveChild() { return this->activeChild_; }
    106 
    107         void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
    108 
    109         virtual GameStateBase* getParent() const = 0;
    110         virtual void setParent(GameStateBase* state) = 0;
     91        virtual void activate() = 0;
     92        virtual void deactivate() = 0;
     93        virtual void update(const Clock& time) = 0;
    11194
    11295    private:
    113         // Making the constructor private ensures that game states
    114         // are always derivates of GameState<T>. Note the friend declaration above.
    115         GameStateBase(const std::string& name);
    116 
    117         //! Performs a transition to 'destination'
    118         virtual void makeTransition(GameStateBase* source, GameStateBase* destination);
    119 
    120         void grandchildAdded(GameStateBase* child, GameStateBase* grandchild);
    121         void grandchildRemoved(GameStateBase* grandchild);
    122 
    123         void tick(const Clock& time);
    124         void activate();
    125         void deactivate();
     96        void setParent(GameState* state) { this->parent_ = state; }
     97        void setActivity(State activity);
     98        void activateInternal();
     99        void deactivateInternal();
     100        void updateInternal(const Clock& time);
    126101
    127102        const std::string                        name_;
    128         Operations                               operation_;
    129         GameStateBase*                           activeChild_;
    130         //bool                                     bPauseParent_;
    131         std::map<std::string, GameStateBase*>    allChildren_;
    132         std::map<GameStateBase*, GameStateBase*> grandchildrenToChildren_;
    133     };
    134 
    135 
    136     template <class ParentType>
    137     class GameState : public GameStateBase
    138     {
    139     public:
    140         GameState(const std::string& name)
    141             : GameStateBase(name)
    142             , parent_(0)
    143         { }
    144         virtual ~GameState() { }
    145 
    146         ParentType* getParent() const
    147             { return parent_; }
    148 
    149     protected:
    150         void setParent(GameStateBase* state)
    151         {
    152             assert(dynamic_cast<ParentType*>(state) != 0);
    153             this->parent_ = dynamic_cast<ParentType*>(state);
    154         }
    155 
    156     private:
    157         ParentType* parent_;
     103        State                                    activity_;
     104        GameState*                               parent_;
     105        std::map<std::string, GameState*>        children_;
    158106    };
    159107}
Note: See TracChangeset for help on using the changeset viewer.