File: displayBase.h

package info (click to toggle)
attal 0.9.2-1.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,992 kB
  • ctags: 5,972
  • sloc: cpp: 44,510; sh: 160; makefile: 45
file content (369 lines) | stat: -rw-r--r-- 7,820 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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/****************************************************************
**
** Attal : Lords of Doom
**
** displayBase.h
** inside the base
**
** Version : $Id: displayBase.h,v 1.9 2004/12/11 13:39:04 lusum Exp $
**
** Author(s) : Pascal Audoux - Sardi Carlo
**
** Date : 03/09/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 DISPLAYBASE_H
#define DISPLAYBASE_H
 
 
// generic include files
// include files for QT
#include <qdialog.h>
#include <qlabel.h>
// application specific includes
#include "libCommon/unit.h"
#include "libCommon/priceMarket.h"
#include "libClient/displayCreature.h"
#include "libClient/player.h"
#include "libClient/widget.h"
#include "libClient/ressourceWin.h"

class AttalSocket;
class BaseSummary;
class BaseLords;
class BaseButtons;
class BaseRightPanel;
class BaseTroop;
class Game;
class GenericBase;
class GenericLord;
class GenericInsideBuilding;
class InsideBase;
class UnitSummary;
class InsideActionAllBuildings;
class DisplayBaseLord;

/*              ------------------------------
 *                         DisplayBase
 *              ------------------------------ */

#define NB_CREATURE_BASE 7

/** Display inside of a base */
class DisplayBase : public QWidget
{
	Q_OBJECT
public:
	/** Construtor */
	DisplayBase( QWidget * parent = 0, const char * name = 0 );

	~DisplayBase();

	/** Initialize the player */
	void setPlayer( Player * player );

	/** Initialize the base to display */
	void setBase( GenericBase * base );

	/** Reinits the display of the base */
	void reinit();

	/** Set socket for sending infos to server */
	void setSocket( AttalSocket * sock );

	/** Gives game info to this object */
	void setGame( Game * game ) { _game = game; }

	/** Handles socket's data */
	void handleSocket();

signals:
	/** Signal for quitting */
	void sig_quit();

public slots:
	/** Slot when a building is clicked */
	void slot_building( GenericInsideBuilding * );

private:
	void actionAllBuildings();

	void actionAllCreatures();

	void actionSomeCreatures( GenericInsideBuilding * building );

	void actionMarket();

	Player * _player;
	GenericBase * _base;
	AttalSocket * _socket;
	
	InsideBase * _inside;
	BaseRightPanel * _panel;
	BaseSummary * _baseSummary;
	Game * _game;
	InsideActionAllBuildings * _dialog;
};

class BaseRightPanel : public QWidget
{
	Q_OBJECT
public:
	BaseRightPanel( QWidget * parent = 0, const char * name = 0 );
	
	/* Initialize player */
	void setPlayer( Player * player );
	
	void setBase( GenericBase * base );
	
	void setSocket( AttalSocket * socket );
	
	void reinit();
signals:
	void sig_quit();
	
public slots:
	void slot_lords();
	
	void slot_info();

protected:
	QPushButton * _pbLord;
	QPushButton * _pbInfo;
	QLabel * _lordLabel;
	BaseButtons * _bases;
	GenericBase * _base;
	Player * _player;
	AttalSocket * _socket;
	DisplayBaseLord * _displayLords;
};

/** Widget for displaying a summary of the base info */
class BaseSummary : public QWidget
{
public:
	/** Constructor */
	BaseSummary( QWidget * parent = 0, const char * name = 0 );

	/** Initialize with the current base to display */
	void setBase( GenericBase * base );

	void reinit();

	/** Initialize the player */
	void setPlayer( Player * player );

private:
	UnitSummary * _unitIco[8];
	GenericBase * _base;
	Player * _player;
	RessourceWin * _ress;
	QLabel * _popul;
};

class DisplayBaseInfo : public QDialog
{
public:
	DisplayBaseInfo( QWidget * parent = 0, const char * name = 0 );
	
	void init( Player * player, GenericBase * base );

	void reinit();

protected:
	BaseSummary * _widget;
};

/** Displays the lord of the base */
class BaseLords : public QWidget
{
	Q_OBJECT
public:
	/** Constructor */
	BaseLords( QWidget * parent = 0, const char * name = 0 );

	/** Initialize with the current base to display */
	void setBase( GenericBase * base );

	/** Reinit the widget */
	void reinit();

	/** Initialize the player */
	void setPlayer( Player * _player );

	/** Tell if there is a visiting lord */
	bool isVisitor() {
		return (_visitor == 0);
	}

	/** Sets the socket for requesting the server */
	void setSocket( AttalSocket * socket ) {
		_socket = socket;
	}

public slots:
	/** Slot for exchange button */
	void slot_exchange();

	/** Slot if the garrison lord is clicked */
	void slot_photoGarrison();

	/** Slot if the visitor lord is clicked */
	void slot_photoVisitor();

	/** Slot if the 'num'-th unit of garrison is clicked */
	void slot_unitGarrison( int num );

	/** Slot if the 'num'-th unit of visit is clicked */
	void slot_unitVisitor( int num );

signals:
	/** Signal for exchanging lords */
	void sig_exchange( bool st );

private:
	void unselectUnits();
	void unselectPhoto();
	void exchangeLords();
	void exchangeUnitsGV();
	void exchangeUnitsVG();
	void exchangeUnitsGG( int u1, int u2 );
	void exchangeUnitsVV( int u1, int u2 );

	bool _isExchange;
	BaseTroop * _garrison, * _visitor;
	GenericBase * _base;
	Player * _player;
	bool _garrisonSelected, _visitorSelected;
	int _unitGarrison, _unitVisitor;
	AttalSocket * _socket;
};

class DisplayBaseLord : public QDialog
{
	Q_OBJECT
public:
	DisplayBaseLord( QWidget * parent = 0, const char * name = 0 );
	
	void init( Player * player, GenericBase * base, AttalSocket * socket );

	void reinit();

protected:
	BaseLords * _widget;
};

/** Button for changing of base */
class BaseButtons : public QWidget
{
	Q_OBJECT
public:
	/** Constructors */
	BaseButtons( QWidget * parent = 0, const char * name = 0 );

	/** Initialize the player */
	void setPlayer( Player * player ) { _player = player; }

public slots:
	/** Slot for exchanging lords */
	void slot_exchange( bool st );

signals:
	/** Signal for quitting */
	void sig_quit();

	/** Signal for exhanging */
	void sig_exchange();

private:
	Player * _player;
	QPushButton * _pbExch;

};

/** Summary of units of a lord */
class UnitSummary : public QWidget
{
public:
	/** Constructor */
	UnitSummary( QWidget * parent = 0, const char * name = 0 );

	/** Initialize the creature to display */
	void setCreature( int id );

	/** Initialize the player */
	void setPlayer( Player * player ) { _player = player; }

	/** Det the number of creatures */
	void setNumber( int num );

private:
	QLabel * _ico, * _nb;
	Player * _player;
};

/** Display troops inside base */
class BaseTroop : public QWidget
{
	Q_OBJECT
public:
	/** Constructor */
	BaseTroop( bool isGarrison, QWidget * parent = 0, const char * name = 0 );

	/** Clear BaseTroop Widget */
	void clear();

	/** Initialize the player */
	void setPlayer( Player * player ) { _player = player; }

	/** Initialize the lord to display */
	void setLord( GenericLord * lord );

	/** Initialize the base to display */
	void setBase( GenericBase * base );

	/** Reinit the widget (to synchronize change) */
	void reinit();

	/** Select the 'photo' widget */
	void selectPhoto() {}

	/** Unselect the 'photo' widget */
	void unselectPhoto() {}

	/** Select unit 'num' */
	void selectUnit( int /*num*/ ) {}

	/** Unselect all units */
	void unselectUnits() {}

signals:
	/** Signal if photo clicked */
	void sig_photo();

	/** Signal if unit clicked */
	void sig_unit( int );

private:
	Icon * _photo;
	Icon * _units[MAX_UNIT];
	bool _isGarrison;
	GenericLord * _lord;
	GenericBase * _base;
	Player * _player;
};

#endif // DISPLAYBASE_H