Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2008, 6:07:57 PM (16 years ago)
Author:
rgrieder
Message:
  • renamed:

GameState —> GameStateBase
GameStateTyped<T> —> GameState

  • moved command line parsing from GSRoot to RootGameState.
File:
1 edited

Legend:

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

    r1688 r1689  
    6161        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
    6262    */
    63     class _CoreExport GameState
     63    class _CoreExport GameStateBase
    6464    {
    6565        friend class RootGameState;
    6666        template <class ParentType>
    67         friend class GameStateTyped;
     67        friend class GameState;
    6868
    6969    public:
     
    8282
    8383    public:
    84         virtual ~GameState();
     84        virtual ~GameStateBase();
    8585
    8686        const std::string& getName() const { return name_; }
    8787        const Operations getOperation() const { return this->operation_; }
    88         bool isInSubtree(GameState* state) const;
     88        bool isInSubtree(GameStateBase* state) const;
    8989
    90         GameState* getState(const std::string& name);
    91         GameState* getRoot();
     90        GameStateBase* getState(const std::string& name);
     91        GameStateBase* getRoot();
    9292        //! Returns the currently active game state
    93         virtual GameState* getCurrentState();
     93        virtual GameStateBase* getCurrentState();
    9494
    9595        virtual void requestState(const std::string& name);
    9696
    97         void addChild(GameState* state);
    98         void removeChild(GameState* state);
     97        void addChild(GameStateBase* state);
     98        void removeChild(GameStateBase* state);
    9999        void removeChild(const std::string& name);
    100100
     
    104104        virtual void ticked(const Clock& time) = 0;
    105105
    106         GameState* getActiveChild() { return this->activeChild_; }
     106        GameStateBase* getActiveChild() { return this->activeChild_; }
    107107
    108108        void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
    109109
    110         virtual GameState* getParent() const = 0;
    111         virtual void setParent(GameState* state) = 0;
     110        virtual GameStateBase* getParent() const = 0;
     111        virtual void setParent(GameStateBase* state) = 0;
    112112
    113113    private:
    114114        // Making the constructor private ensures that game states
    115         // are always derivates of GameStateTyped<T>. Note the friend declaration above.
    116         GameState(const std::string& name);
     115        // are always derivates of GameState<T>. Note the friend declaration above.
     116        GameStateBase(const std::string& name);
    117117
    118118        //! Performs a transition to 'destination'
    119         virtual void makeTransition(GameState* source, GameState* destination);
     119        virtual void makeTransition(GameStateBase* source, GameStateBase* destination);
    120120
    121         void grandchildAdded(GameState* child, GameState* grandchild);
    122         void grandchildRemoved(GameState* grandchild);
     121        void grandchildAdded(GameStateBase* child, GameStateBase* grandchild);
     122        void grandchildRemoved(GameStateBase* grandchild);
    123123
    124124        void tick(const Clock& time);
     
    126126        void deactivate();
    127127
    128         const std::string                   name_;
    129         Operations                          operation_;
    130         GameState*                          activeChild_;
    131         //bool                                bPauseParent_;
    132         std::map<std::string, GameState*>   allChildren_;
    133         std::map<GameState*, GameState*>    grandchildrenToChildren_;
     128        const std::string                        name_;
     129        Operations                               operation_;
     130        GameStateBase*                           activeChild_;
     131        //bool                                     bPauseParent_;
     132        std::map<std::string, GameStateBase*>    allChildren_;
     133        std::map<GameStateBase*, GameStateBase*> grandchildrenToChildren_;
    134134    };
    135135
     136
    136137    template <class ParentType>
    137     class GameStateTyped : public GameState
     138    class GameState : public GameStateBase
    138139    {
    139140    public:
    140         GameStateTyped(const std::string& name) : GameState(name) { }
    141         virtual ~GameStateTyped() { }
     141        GameState(const std::string& name) : GameStateBase(name) { }
     142        virtual ~GameState() { }
    142143
    143144        ParentType* getParent() const
     
    145146
    146147    protected:
    147         void setParent(GameState* state)
     148        void setParent(GameStateBase* state)
    148149        {
    149150            assert(dynamic_cast<ParentType*>(state) != 0);
Note: See TracChangeset for help on using the changeset viewer.