SVN_SILENT made messages (.desktop file)
[kdegames.git] / konquest / gameview.h
blob82a0e46e7ec6876c2f0ee4be64bddd938d7c238a
1 /*
2 Copyright Russell Steffen <rsteffen@bayarea.net>
3 Copyright Stephan Zehetner <s.zehetner@nevox.org>
4 Copyright Dmitry Suzdalev <dimsuz@gmail.com>
5 Copyright <inge@lysator.liu.se>
6 Copyright <pinaraf@gmail.com>
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.
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.
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.
22 #ifndef _GAMEVIEW_H_
23 #define _GAMEVIEW_H_
26 #include <QWidget>
28 #include "planet.h"
29 #include "player.h"
32 //************************************************************************
33 // forward declarations
34 //************************************************************************
37 class QLabel;
38 class QPushButton;
39 class QLineEdit;
40 class QTextEdit;
42 class KLocalizedString;
44 class Player;
45 class MapView;
46 class MapScene;
47 class GameLogic;
50 struct GameMessage {
51 QString text;
52 Player *sender;
53 Player *receiver;
57 enum GUIState {
58 NONE,
59 SOURCE_PLANET,
60 DEST_PLANET,
61 SHIP_COUNT,
62 RULER_SOURCE,
63 RULER_DEST
67 //************************************************************************
68 // GameView Widget
69 //************************************************************************
72 class GameView : public QWidget
74 Q_OBJECT
76 public:
77 explicit GameView( QWidget *parent, GameLogic *gameLogic );
78 virtual ~GameView();
80 // virtual QSize sizeHint() const;
82 bool isGameInProgress() const { return m_gameInProgress; }
84 protected slots:
85 void startNewGame();
86 void shutdownGame();
87 void planetSelected( Planet * );
88 void newShipCount();
89 void nextPlayer();
91 //***************************************************************
92 // Toolbar items
93 //***************************************************************
94 void measureDistance();
95 void showScores();
96 void showFleets();
98 public slots:
99 void gameMsg(const KLocalizedString &msg, Player *player = 0,
100 Planet *planet = 0, Player *planetPlayer = 0);
101 void beginTurn();
102 void endTurn();
104 signals:
105 void newGUIState( GUIState newState );
107 //***************************************************************
108 // Event Handlers
109 //***************************************************************
110 protected:
111 virtual void keyPressEvent( QKeyEvent * );
112 virtual void resizeEvent ( QResizeEvent * event );
114 private:
115 void turn();
116 void gameOver();
118 void sendAttackFleet( Planet *source, Planet *dest, int ships );
120 void changeGameView( bool inPlay );
121 void cleanupGame();
124 //***************************************************************
125 // Display Widgets
126 //***************************************************************
128 MapView *m_mapWidget;
129 MapScene *m_mapScene;
130 QLabel *m_gameMessage;
131 QPushButton *m_endTurnBtn;
132 QLineEdit *m_shipCountEdit;
133 QLabel *m_splashScreen;
134 QTextEdit *m_msgWidget;
136 //***************************************************************
137 // Game objects
138 //***************************************************************
140 GameLogic *m_gameLogic;
142 Player *m_neutralPlayer; // FIXME: Have here or in gamelogic?
143 bool m_queueMessages;
144 QList<GameMessage> m_messageQueue;
145 bool m_showInformations;
147 // States in the user interaction
148 // FIXME: Break out into another file?
149 bool haveSourcePlanet;
150 Planet *sourcePlanet;
152 bool haveDestPlanet;
153 Planet *destPlanet;
155 bool haveShipCount;
156 int shipCount;
158 //***************************************************************
159 // Game State information
160 //***************************************************************
162 bool m_gameInProgress;
163 GUIState m_guiState;
167 #endif