1 #ifndef GRAPHICS_GAME_VIEW_HH |
1 #ifndef GRAPHICS_GAME_VIEW_HH |
2 #define GRAPHICS_GAME_VIEW_HH |
2 #define GRAPHICS_GAME_VIEW_HH |
3 |
3 |
4 #include "Drawable.hh" |
4 #include "Drawable.hh" |
|
5 #include "PlayerInfoView.hh" |
|
6 #include "MessageView.hh" |
5 #include "../GameState.hh" |
7 #include "../GameState.hh" |
6 |
8 |
7 namespace graphics |
9 namespace graphics |
8 { |
10 { |
9 |
11 |
10 /** |
12 /** |
11 * This is the main in-game view, which is what the player sees when they are playing |
13 * This is the main in-game view, which is what the player sees when they are playing |
12 */ |
14 */ |
13 class GameView : public Drawable { |
15 class GameView : public View { |
14 protected: |
16 protected: |
15 /** The GameState that we're drawing */ |
17 /** The GameState that we're drawing */ |
16 GameState &state; |
18 GameState &state; |
17 |
19 |
18 /** The player that we are controlling, if any */ |
20 /** The player that we are controlling, if any */ |
19 LocalPlayer *player; |
21 LocalPlayer *player; |
20 |
22 |
|
23 /** |
|
24 * The PlayerInfo view is built once we have a player |
|
25 */ |
|
26 PlayerInfoView *info_view; |
|
27 |
|
28 /** |
|
29 * The message list view |
|
30 */ |
|
31 MessageView message_view; |
|
32 |
21 public: |
33 public: |
22 /** |
34 /** |
23 * Constructed once the game is running |
35 * Constructed once the game is running |
24 */ |
36 */ |
25 GameView (GameState &state, LocalPlayer *player) : |
37 GameView (GameState &state, LocalPlayer *player); |
26 state(state), player(player) |
|
27 { |
|
28 |
|
29 } |
|
30 |
38 |
31 /** |
39 /** |
32 * Set a player where none was set before |
40 * Set a player where none was set before |
33 */ |
41 */ |
34 void setPlayer (LocalPlayer *player) { |
42 void setPlayer (LocalPlayer *player); |
35 assert(!this->player); |
43 |
36 |
44 private: |
37 // remember it |
45 /** |
38 this->player = player; |
46 * Calculate new area for the info_view based on our own area |
|
47 */ |
|
48 PixelArea getInfoViewArea (void) { |
|
49 return PixelArea(0, area.bottom - 100, area.right, area.bottom); |
39 } |
50 } |
|
51 |
|
52 /** |
|
53 * Calculate new area for the message view |
|
54 */ |
|
55 PixelArea getMessageViewArea (void) { |
|
56 return PixelArea(400, area.bottom - 100, area.right, area.bottom); |
|
57 } |
|
58 |
|
59 public: |
40 |
60 |
41 /** |
61 /** |
42 * Draw this view onto the given display |
62 * Draw this view onto the given display |
43 */ |
63 */ |
44 void draw (Display *display); |
64 virtual void draw (Display *display); |
|
65 |
|
66 /** |
|
67 * Resize sub-views |
|
68 */ |
|
69 virtual void resize (const PixelArea &new_area); |
45 }; |
70 }; |
46 |
71 |
47 } |
72 } |
48 #endif |
73 #endif |