File: clientInterface.h

package info (click to toggle)
attal 0.9.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,992 kB
  • ctags: 5,972
  • sloc: cpp: 44,510; sh: 134; makefile: 45
file content (210 lines) | stat: -rw-r--r-- 4,281 bytes parent folder | download | duplicates (2)
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
/****************************************************************
**
** Attal : Lords of Doom
**
** clientInterface.h
** Manages the whole game
**
** Version : $Id: clientInterface.h,v 1.17 2004/12/11 13:39:04 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 <qapplication.h>
#include <qdialog.h>
#include <qlineedit.h>
#include <qmainwindow.h>
#include <qptrvector.h>
#include <qstring.h>
// application specific includes
#include "libCommon/displayHelp.h"
#include "libCommon/genericBuilding.h"
#include "libClient/player.h"
#include "libClient/game.h"
#include "libClient/gui.h"


class QAction;
class QPopupMenu;

class AttalSocket;
class DisplayBase;
class Fight;
class GainLevel;
class GenericLord;
class ConfigConnection;

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


/** comment for the class */
class ClientInterface : public QMainWindow
{
	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 );

	/** 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(int e);

	/** 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 );

protected:
	void closeEvent( QCloseEvent* );

private:
	enum MENU_ACTIONS {
		ACTION_CONNECT = 0,
		ACTION_FASTCONNECT ,
		ACTION_DISCONNECT,
		ACTION_MINIMAP,
		ACTION_TAB,
		ACTION_FULL,
		ACTION_HELP,
		ACTION_QUIT,

		NB_ACTIONS
	};

	enum StateGame {
		SG_MAP,
		SG_FIGHT,
		SG_BASE
	};

	enum choice	{ 
		END_GAME,
		QUIT_GAME
	};

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

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

	void initActions();

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

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

	void showFightResults( char result );

	void updateUnits();

	void actionConnect(bool fast);
	
	void actionFastConnect();

	void actionDisconnect(int choice);

	void actionMinimap();
	
	void actionTab();
	
	void actionFullScreen();

	void actionHelp();
	
	void actionQuit();

	Game * _game;
	Fight * _fight;
	DisplayBase * _base;
	AttalSocket * _socket;
	GainLevel * _level;
	ConfigConnection * _config;
	bool _mini;
	bool _tab,_full;
	QPtrVector<QAction> _actions;
	DisplayHelp * _help;

	StateGame _state;
};

/** Dialog for configuring connection to server */
class ConfigConnection : public QDialog
{
	Q_OBJECT
public:
	/** Constructor */
	ConfigConnection( QWidget * parent = 0, const char * name = 0 );

	/** Setting hostname */
	void setHost( QString host ) { _host->setText( host ); }

	/** Getting hostname */
	QString getHost() { return _host->text(); }

	int getPort() { return _port->text().toInt(); }

	/** Setting port number */
	void setPort( int port ) { _port->setText( QString::number( port ) ); }

	/** Getting player's name */
	QString getPlayerName() { return _name->text(); }

	/** Setting player's name */
	void setPlayerName( QString name ) { _name->setText( name ); }
	
	void accept() { QDialog::accept(); }

private:
	QLineEdit * _host, * _port, * _name;
};

#endif // CLIENTINTERFACE_H