File: clientInterface.h

package info (click to toggle)
attal 1.0~rc2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 4,348 kB
  • ctags: 7,428
  • sloc: cpp: 55,101; sh: 267; ansic: 100; makefile: 54
file content (328 lines) | stat: -rw-r--r-- 5,968 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/****************************************************************
**
** Attal : Lords of Doom
**
** clientInterface.h
** Manages the whole game
**
** Version : $Id: clientInterface.h,v 1.70 2008/05/24 16:04:25 lusum Exp $
**
** Author(s) : Pascal Audoux - Sardi Carlo
**
** Date : 17/08/2000
**
** Licence :
**	This program is free software; you can redistribute it and/or modify
**   	it under the terms of the GNU General Public License as published by
**     	the Free Software Foundation; either version 2, or (at your option)
**      any later version.
**
**	This program is distributed in the hope that it will be useful,
** 	but WITHOUT ANY WARRANTY; without even the implied warranty of
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**	GNU General Public License for more details.
**
****************************************************************/


#ifndef CLIENTINTERFACE_H
#define CLIENTINTERFACE_H

// include files for QT
#include <QAbstractSocket>
#include <QApplication>
#include <QCloseEvent>
#include <QDialog>
#include <QLineEdit>
#include <QMainWindow>
#include <QKeySequence>
#include <QString>
#include <QVector>
#include <QStackedWidget>

// application specific includes
#include "libCommon/displayHelp.h"
#include "libCommon/genericBuilding.h"
#include "libClient/player.h"
#include "libClient/game.h"
#include "libClient/gui.h"
#include "libClient/ressourceBar.h"
#include "libServer/loadGame.h"



class QProcess;

class QAction;
class QProgressDialog;
class QSignalMapper;

class AttalSocket;
class DisplayBase;
class Fight;
class GainLevel;
class GenericLord;
class ConfigConnection;
class StartGameDialog;
class AttalMessage;
class AttalServer;
class Engine;
class Analyst;

/*              ------------------------------
 *                      ClientInterface
 *              ------------------------------ */


class ClientInterface : public QMainWindow,  public LoadGame
{
	Q_OBJECT
public:
	/** Constructor */
	ClientInterface();

	/** Destructor */
	~ClientInterface();

public slots:
	/** Slot for managing 'actions' */
	void slot_action( int num );

	/** Slot for writing in the StatusBar */
	void slot_status( const QString & text );
	
	void slot_scenInfo( const QString & text );

	/** Slot for reading the socket */
	void slot_readSocket();
	
	/** when connection is closed by server **/
	void slot_connectionClosed();
	
	void slot_endGame();
	
	void slot_exchange();
	
	void slot_hostfound();
	
	/** manage connection's errors **/
	void slot_error( QAbstractSocket::SocketError error );

	/** Slot for displaying the base */
	void slot_base( GenericBase * base );

	/** Slot for quitting the base */
	void slot_map();

	/** Slot for beginning fight */
	void slot_fight( GenericLord * lord, CLASS_FIGHTER cla );
	
	void slot_clientConnect();

	void slot_quit() { actionQuit(); }
	
	void slot_newScen();
	
	void slot_newCamp();
	
	void slot_loadScen();
	
	void slot_loadCamp();
	
	void slot_dialogClosed();

	void slot_ready();
	
	void slot_endConnection( QString name );

	void slot_endTurn();
	
	void slot_beginTurn();

	void slot_result(bool result);
	
	void slot_resourceBar();

	void slot_loadThemeStep();
	
	void actionOptionsAnimations(int state);

#ifdef WITH_SOUND
	void actionOptionsMusic(int state);

	void actionOptionsSound(int state);
#endif

signals:
	
	void sig_newMessage( const QString & );

	void sig_map();
	
	void sig_baseDisplay();
	
	void sig_fightDisplay();
	
	void sig_widgChanged( int );
	
	void sig_animations();
	
	void sig_dispositions();

protected:
	void closeEvent( QCloseEvent* );
	
	void updateScreen();

	void resizeWidget();
	
	virtual void changeEvent ( QEvent * e );

private:
	enum MENU_ACTIONS {
		ACTION_CONNECT = 0,
		ACTION_START,
		ACTION_END,
		ACTION_SAVE,
		ACTION_FASTCONNECT ,
		ACTION_DISCONNECT,
		ACTION_MINIMAP,
		ACTION_FULL,
		ACTION_CHAT,
		ACTION_OPTIONS,
		ACTION_INFO,
		ACTION_ENDTURN,
		ACTION_NEXTLORD,
		ACTION_NEXTBASE,
		ACTION_HELP,
		ACTION_ABOUT,
		ACTION_QUIT,
		
		ACTION_FREESIZE,
		ACTION_800,
		ACTION_1024,
		ACTION_1280,

		ACTION_TESTSTYLE,

		NB_ACTIONS
	};

	enum StateGame {
		SG_MAP,
		SG_FIGHT,
		SG_BASE
	};

	enum SizeMode {
		SIZEMODE_FREE,
		SIZEMODE_800,
		SIZEMODE_1024,
		SIZEMODE_1280
	};

	/** Define menus */
	void initMenuBar();

	/** Define statusBar */
	void initStatusBar();

	void initActions();

	void initProgressBar();
	
	void loadMenu( bool show );

	/** Add a new action */
	QAction * addAction( const QString & label, const QKeySequence & shortcut, MENU_ACTIONS id, QSignalMapper * sigmap );

	/** Manage socket SO_FIGHT */
	void socketFight();

	/** Manage socket QR */
	void socketQR();

	void showFightResults( char result );

	void updateUnits();

	void actionConnect(bool fast);

	void actionStart();

	void actionEnd();
	
	void actionFastConnect();

	void actionDisconnect();

	void actionMinimap();
	
	void actionFullScreen();
		
	void actionPopupChat();
	
	void actionOptions();
	
	void actionInfo();
	
	void actionNextLord();
	
	void actionNextBase();

	void actionHelp();

	void actionAbout();

	bool actionQuit();
	
	void actionResize( SizeMode mode );

	void actionTestStyle();
	
	void killServer();
	
	void addInternalAI();
	
	bool killAI();
				
	void adjustWidgetLoading(  StatusWidget type );

	void endEngine();

	void endServer();

	void disconnectClient();
	
	void disconnectAI();
	
	void reinit();

	Game * _game;
	Fight * _fight;
	DisplayBase * _base;
	AttalSocket * _socket;
	GainLevel * _level;
	ConfigConnection * _config;
	StartGameDialog * _startDialog;
	bool _mini, _inLoad;
	bool _full;
	QProcess * _proc;
	QVector<QAction *> _actions;
	QList<Analyst *> _aiList;
	DisplayHelp * _help;
	QStackedWidget * _centralWindow;
	AttalMessage * _msg;
	QProgressDialog * _progress;
	int _progressNum;
	QString _scenInfo;
	QStatusBar * _statusBar;
	RessourceBar * _resourceBar;
	QLabel * _cal;
	int _numWidg[3];
	QSignalMapper * _sigmap;

	StateGame _state;
};

#endif // CLIENTINTERFACE_H