File: PlayGroundMenu.h

package info (click to toggle)
moagg 0.18-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,924 kB
  • ctags: 4,059
  • sloc: cpp: 23,814; sh: 2,652; makefile: 283
file content (116 lines) | stat: -rw-r--r-- 2,675 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef PLAYGROUND_MENU_H
#define PLAYGROUND_MENU_H

#include <pgmessageobject.h>

#include "Ship.h"
#include "GameControlBase.h"
#include "SinglePlayerGame.h"

#include "Menu.h"

 //----------------------------------------------------------------------------
#undef DECLARE_UPDATE_STATE
#define DECLARE_UPDATE_STATE(c) \
  class c; \
  friend class c; \
  class c : public UpdateState \
  { \
      STATE_OBJECT(c); \
    public: \
      c() {} \
      ~c() {} \
      void updateScreen(PlayGroundMenu *driver); \
  }



//----------------------------------------------------------------------------
class PlayGroundMenu : public Menu
{
  MENU_SINGLETON(PlayGround);

  //------------------------------------------------------------------------
  class UpdateState
  {
    protected:
      UpdateState() {}
    public:
      virtual ~UpdateState() {}

      virtual void updateScreen(PlayGroundMenu *driver) = 0;
  };

  DECLARE_UPDATE_STATE(FullFrameRateInitial);
  DECLARE_UPDATE_STATE(FullFrameRate);

  DECLARE_UPDATE_STATE(RelativeUpdate);
  DECLARE_UPDATE_STATE(FullUpdateDelay);

  public:
    //------------------------------------------------------------------------
    void eventShow();
    void eventHide();

    inline void setMission(const std::string &mission)
    {
        m_mission = mission;
    }

    inline void setLevel(unsigned level)
    {
        m_level = level;
    }

    //------------------------------------------------------------------------
    inline void updateScreen()
    {
      m_state->updateScreen(this);
    }

    //------------------------------------------------------------------------
    void initUpdateState();

    //------------------------------------------------------------------------
    inline void setState(UpdateState *state)
    {
        m_state = state;
    }

    /**
     * Redraws the standard background.
     */
    void restoreBackground();

    const SDL_Surface* getLevelPreview();

  protected:
    bool eventKeyUp(const SDL_KeyboardEvent *key);
    bool eventKeyDown(const SDL_KeyboardEvent *key);
    bool eventMessage (MSG_MESSAGE *msg);
    bool eventQuit(int id, PG_MessageObject *widget, unsigned long data);

    void trigger();
    void initLevel();

    void updateViewBox();
    bool hasViewBoxChanged() const;
    void do_playGroundRelativeUpdate();
    void do_playGroundFullUpdate();

    SDL_Rect m_viewBox;
    SDL_Rect m_oldViewBox;

    UpdateState *m_state;

    bool m_initialized;
    bool m_quit;
    bool m_ingame;
    bool m_fireDown;
    std::string m_mission;
    unsigned m_level;
    SinglePlayerGame* m_game;
    SDL_Surface *m_backSurface;
};

#endif // PLAYGROUND_MENU_H