1 | /* |
2 | Copyright 2003 Russell Steffen <rsteffen@bayarea.net> |
3 | Copyright 2003 Stephan Zehetner <s.zehetner@nevox.org> |
4 | Copyright 2006 Dmitry Suzdalev <dimsuz@gmail.com> |
5 | Copyright 2006 Inge Wallin <inge@lysator.liu.se> |
6 | Copyright 2006 Pierre Ducroquet <pinaraf@gmail.com> |
7 | |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef KONQUEST_GAMEVIEW_H |
24 | #define KONQUEST_GAMEVIEW_H |
25 | |
26 | #include <QWidget> |
27 | |
28 | #include "planet.h" |
29 | #include "players/player.h" |
30 | #include "game.h" |
31 | |
32 | //************************************************************************ |
33 | // forward declarations |
34 | //************************************************************************ |
35 | |
36 | class QCheckBox; |
37 | class QDockWidget; |
38 | class QLabel; |
39 | class QPushButton; |
40 | class QLineEdit; |
41 | class QTextEdit; |
42 | class QIntValidator; |
43 | |
44 | class KLocalizedString; |
45 | |
46 | class Player; |
47 | class MapView; |
48 | class MapScene; |
49 | class GameLogic; |
50 | class StandingsWidget; |
51 | |
52 | |
53 | struct GameMessage { |
54 | QString text; |
55 | Player *sender; |
56 | Player *receiver; |
57 | }; |
58 | |
59 | |
60 | enum GUIState { |
61 | NONE, |
62 | SOURCE_PLANET, |
63 | DEST_PLANET, |
64 | SHIP_COUNT, |
65 | RULER_SOURCE, |
66 | RULER_DEST |
67 | }; |
68 | |
69 | |
70 | //************************************************************************ |
71 | // GameView Widget |
72 | //************************************************************************ |
73 | |
74 | |
75 | class GameView : public QWidget |
76 | { |
77 | Q_OBJECT |
78 | |
79 | public: |
80 | explicit GameView(QWidget *parent, Game *game, QDockWidget *messagesDock, QDockWidget *standingsDock); |
81 | virtual ~GameView(); |
82 | bool confirmNewGame(); |
83 | |
84 | protected slots: |
85 | bool shutdownGame(); |
86 | void planetSelected( Planet * ); |
87 | void newShipCount(); |
88 | void nextPlayer(); |
89 | void standingOrdersClicked(); |
90 | |
91 | //*************************************************************** |
92 | // Toolbar items |
93 | //*************************************************************** |
94 | void measureDistance(); |
95 | void showFleets(); |
96 | |
97 | public slots: |
98 | void startNewGame(); |
99 | void gameMsg(const KLocalizedString &msg, Player *player = 0, |
100 | Planet *planet = 0, Player *planetPlayer = 0); |
101 | void turnPreparation(); |
102 | |
103 | signals: |
104 | void newGUIState( GUIState newState ); |
105 | |
106 | //*************************************************************** |
107 | // Event Handlers |
108 | //*************************************************************** |
109 | protected: |
110 | virtual void keyPressEvent( QKeyEvent * ); |
111 | virtual void resizeEvent ( QResizeEvent * event ); |
112 | |
113 | private slots: |
114 | void gameOver(); |
115 | |
116 | private: |
117 | void changeGameView(); |
118 | void cleanupGame(); |
119 | |
120 | void turn(); |
121 | |
122 | //*************************************************************** |
123 | // Display Widgets |
124 | //*************************************************************** |
125 | |
126 | MapView *m_mapWidget; |
127 | MapScene *m_mapScene; |
128 | QLabel *m_gameMessage; |
129 | QPushButton *m_endTurnBtn; |
130 | QLineEdit *m_shipCountEdit; |
131 | QCheckBox *m_standingOrder; |
132 | QIntValidator *m_shipValidator; |
133 | QLabel *m_splashScreen; |
134 | |
135 | QTextEdit *m_msgWidget; |
136 | int m_msgWidgetLastTurn; |
137 | |
138 | StandingsWidget *m_standingsWidget; |
139 | |
140 | QDockWidget *m_messagesDock; |
141 | QDockWidget *m_standingsDock; |
142 | |
143 | //*************************************************************** |
144 | // Game objects |
145 | //*************************************************************** |
146 | |
147 | Game *m_game; |
148 | |
149 | bool m_queueMessages; |
150 | QList<GameMessage> m_messageQueue; |
151 | bool m_showInformations; |
152 | bool m_initCompleted, m_cleanupNeeded; |
153 | |
154 | // States in the user interaction |
155 | // FIXME: Break out into another file? |
156 | bool haveSourcePlanet; |
157 | Planet *sourcePlanet; |
158 | |
159 | bool haveDestPlanet; |
160 | Planet *destPlanet; |
161 | |
162 | bool haveShipCount, standingOrder; |
163 | int shipCount; |
164 | |
165 | //*************************************************************** |
166 | // Game State information |
167 | //*************************************************************** |
168 | GUIState m_guiState; |
169 | }; |
170 | |
171 | #endif // KONQUEST_GAMEVIEW_H |
172 | |