File: gameControl.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 (241 lines) | stat: -rw-r--r-- 5,008 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
/****************************************************************
**
** Attal : Lords of Doom
**
** gameControl.h
** Widget on the right, controlling the game
**
** Version : $Id: gameControl.h,v 1.5 2004/12/11 13:33:43 lusum Exp $
**
** Author(s) : Pascal Audoux
**
** Date : 02/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 GAMECONTROL_H
#define GAMECONTROL_H
 
 
// generic include files
// include files for QT
#include <qwidget.h>
// application specific includes
#include "libClient/player.h"
 
class QPushButton;
class QSignalMapper;
class CentralControl;
class ScrollLord;
class ScrollBase;
 
/*              ------------------------------
 *                         GameControl
 *              ------------------------------ */



/** comment for the class */
class GameControl : public QWidget
{
	Q_OBJECT
public:
	/** Constructor */
	GameControl( QWidget * parent = 0, const char * name = 0 );
	
	/** Associate a player */
	void setPlayer( Player * player );
	
	/** Reinit widgets */
	void reinit();
	
	/** Select first lord (if none : first base) */
	void selectFirst();

	/** Disable if no game is running */
	void disableGame();
	
	/** Activate if a game is running */
	void enableGame(); 
		
public slots:
	/** Slot when lord selected */
	void slot_lordSelected();
	
	/** Slot when base selected */
	void slot_baseSelected();
	
signals:
	/** Signal if lord selected clicked */
	void sig_lord();
	
	/** Signal if base selected clicked */
	void sig_base();
	
	/** Signal if 'End Turn' button clicked */
	void sig_endTurn();
	
private:
	CentralControl * _cen;
	ScrollLord * _scrL;
	ScrollBase * _scrB;
	Player * _player;
};

/**Central widget of the GameControl (other actions) */
class CentralControl : public QWidget
{
	Q_OBJECT
public:
	/** Constructor */
	CentralControl( QWidget * parent = 0, const char * name = 0 );

	/** Initialize player */
	void setPlayer( Player * player ) { _player = player; }
	
	/** Disable panel (not in game) */
	void disableGame();
	
	/** Enable panel (in game) */
	void enableGame();
	
signals:
	/** Signal if 'End Turn' button is clicked */
	void sig_endTurn();
	
private slots:
	void slot_nextLord() { _player->nextLord(); }
	
	void slot_options ();
	
	void slot_quit ();
	
private:
	Player * _player;
	QPushButton * _pbQuit, * _pbNext, * _pbTurn, * _pbOptions;
};

/** Scrolling list of buttons */
class ScrollList : public QWidget
{
	Q_OBJECT
public:
	/** Constructor */
	ScrollList( bool horizontal = true, QWidget * parent = 0, const char * name = 0 );

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

	/** Reinit info displayed */
	virtual void reinit() =0;

	/** Select a button in the list */
	void select( int );

	/** Deselect all the buttons */
	void deselect();

	/** Enable 'in game' features */
	void enableGame();

public slots:
	/** Slot when 'up' arrow is clicked */
	void slot_up();

	/** Slot when 'down' arrow is clicked */
	void slot_down();

	/** Slot when a button is clicked */
	virtual void slot_clicked( int ) {}

protected:
	virtual uint getListCount() = 0;

	QSignalMapper * _sigmap;
	QPushButton * _buttons[5];
	Player * _player;
	uint _current;
	int _selected;
	bool _horizontal;
};

/** Scrolling list of lords */
class ScrollLord : public ScrollList
{
	Q_OBJECT
public:
	/** Constructor */
	ScrollLord( bool horizontal = true, QWidget * parent = 0, const char * name = 0 );

	/** Reinit info displayed */
	void reinit();

	/** Select button 'num' */
	void select( int num );

	/** Deselect all buttons */
	void deselect();

signals:
	/** Signal when lord is clicked */
	void sig_lord();

	/** Signal when lord is selected */
	void sig_lordSelected();

public slots:
	/** Slot when a button is clicked */
	void slot_clicked( int );

protected:
	uint getListCount();

	QPtrList<GenericLord> _lordList;

};

/** Scrolling list of bases */
class ScrollBase : public ScrollList
{
	Q_OBJECT
public:
	/** Constructor */
	ScrollBase( bool horizontal = true, QWidget * parent = 0, const char * name = 0 );
	
	/** Reinit info displayed */
	void reinit();	
	
	/** Select button 'num' */
	void select( int num );
	
	/** Deselect all the buttons */
	void deselect();
	
signals:
	/** Signal when base is clicked */
	void sig_base();
	
	/** Signal when base is selected */
	void sig_baseSelected();
	
public slots:
	/** Slot when a button is clicked */
	void slot_clicked( int );

protected:
	uint getListCount();
};

#endif // GAMECONTROL_H