summaryrefslogtreecommitdiffstats
path: root/atlantikdesigner/designer/editor.h
blob: ebc768d30b5521c1390d8e47923ddc65c926392c (plain)
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
#ifndef ATLANTIK_EDITOR_H
#define ATLANTIK_EDITOR_H

#include <kmainwindow.h>
#include <tqstring.h>
#include <tqcolor.h>
#include <tqstringlist.h>

#include <atlantic/estate.h>

#include "group.h"

class TQCheckBox;
class TQGridLayout;
class TQLineEdit;
class TQSpinBox;

class KColorButton;
class KComboBox;
class KListBox;
class KPushButton;

enum EstateType { Street = 0, Cards, FreeParking, ToJail, Tax, Jail };

class ConfigEstate : public Estate
{
	public:
	ConfigEstate(int estateId);
	void setEstateId(const int estateId);
	int type()const { return m_type; }
	void setType(const int type);
	const TQString &group() { return m_group; }
	void setGroup(const TQString &group);
	int price()const { return m_price; }
	void setPrice(int);
	int rent(int _h)const { return m_rent[_h]; }
	void setRent(const int, const int);
	int tax()const { return m_tax; }
	void setTax(const int);
	int taxPercentage() { return m_taxPercentage; }
	void setTaxPercentage(const int);
	const TQString &takeCard() { return m_takeCard; }
	void setTakeCard(const TQString &);
	const TQColor &forceBg() { return m_forceBg; }
	void setForceBg(const TQColor &);
	bool go()const { return m_go; }
	void setGo(const bool);
	int passMoney()const { return m_passMoney; }
	void setPassMoney(const int);

	void setChanged(bool);

	private:
	int m_type;
	TQString m_group;
	int m_rent[6];
	int m_price;
	int m_tax;
	int m_taxPercentage;
	TQString m_takeCard;
	TQColor m_forceBg;
	bool m_go;
	int m_passMoney;
};
typedef TQPtrList<ConfigEstate> EstateList;

struct Card
{
	Card() {}
	Card(const TQString &newName) { name = newName; }
	TQString name;
	TQStringList keys;
	TQValueList<int> values;
};
class CardStack : public TQValueList<Card>
{
	public:
	CardStack() {}
	CardStack(const TQString &newName) { setName(newName); }
	const TQString &name() { return m_name; }
	void setName(const TQString &newName) { m_name = newName; }

	private:
	TQString m_name;
};

class EstateDlg : public QWidget
{
	Q_OBJECT

	public:
	EstateDlg(TQWidget *parent = 0, char *name = 0) : TQWidget(parent, name) { estate = 0; }

	signals:
	void updateBackground();

	public slots:
	virtual void slotOk() { save(); }
	void slotUpdate(ConfigEstate *newEstate) { estate = newEstate; if (estate) update(); }
	void groupsChanged() { groupUpdate(); }

	protected:
	virtual void update() {}
	virtual void save() {}
	virtual void groupUpdate() {}
	ConfigEstate *estate;
};

class EstateEdit : public QWidget
{
	Q_OBJECT

	public:
	EstateEdit(ConfigEstateGroupList *, EstateList *, TQValueList<CardStack> *, TQWidget *parent = 0, const char *name = 0);
	ConfigEstate *theEstate() { return estate; }
	bool upArrow()const;
	bool downArrow()const;
	bool leftArrow()const;
	bool rightArrow()const;
	void aboutToDie();
	void setReady(bool);

	public slots:
	void setEstate(ConfigEstate *);
	ConfigEstate *saveEstate(bool superficial = false);
	void groupsChanged();

	signals:
	void somethingChanged();
	void modified();
	void updateBackground();
	void goChecked(int id);
	void resized();

	protected:
    void resizeEvent(TQResizeEvent *);

	private slots:
	void configure();
	void goToggled(bool);

	private:
	KComboBox *typeCombo;
	TQLineEdit *nameEdit;
	TQCheckBox *goCheck;
	TQSpinBox *passMoney;
	TQWidget *centerWidget;
	TQGridLayout *layout;

	EstateList *estates;
	TQValueList<CardStack> *cards;
	ConfigEstateGroupList *groups;

	ConfigEstate *estate;

	EstateDlg *confDlg;

	int oldType;

	bool ready;
	bool locked;
};

class ChooseWidget : public QWidget
{
	Q_OBJECT

	public:
	ChooseWidget(EstateList *, int id, Card *, TQWidget *parent = 0, char *name = 0);

	public slots:
	void typeChanged(int);
	void valueChanged(int);
	void estateChanged(int);

	private:
	Card *card;
	KComboBox *typeCombo;
	TQSpinBox *value;
	KComboBox *estate;
	bool number;
	bool prevNumber;
	bool init;
	TQHBoxLayout *hlayout;

	EstateList *estates;

	int id;
};

class CardView : public QWidget
{
	Q_OBJECT

	public:
	CardView(EstateList *, CardStack *, TQWidget *parent = 0, char *name = 0);

	private slots:
	void selected(int);
	void add();
	void del();
	void rename();
	void more();
	void less();
	void updateButtonsEnabled();

	private:
	KListBox *List;
	KPushButton *addButton;
	KPushButton *renameButton;
	KPushButton *delButton;
	KPushButton *moreButton;
	KPushButton *lessButton;

	EstateList *estates;

	TQVBoxLayout *layout;

	Card *card;

	CardStack *stack;
	TQPtrList<ChooseWidget> choosies;
};

class TaxDlg : public EstateDlg
{
	Q_OBJECT

	public:
	TaxDlg(TQWidget *parent = 0, char *name = 0);

	protected:
	virtual void save();
	virtual void update();

	private:
	TQSpinBox *tax;
	TQSpinBox *taxPercentage;
};

class GenericDlg : public EstateDlg
{
	Q_OBJECT

	public:
	GenericDlg(TQWidget *parent = 0, char *name = 0);

	protected:
	virtual void save();
	virtual void update();

	private:
	KColorButton *col;
};

class CardsDlg : public EstateDlg
{
	Q_OBJECT

	public:
	CardsDlg(EstateList *, TQValueList<CardStack> *, TQWidget *parent = 0, char *name = 0);

	protected:
	virtual void save();
	virtual void update();

	private slots:
	void addStack();
	void updateView(const TQString &);

	private:
	TQValueList<CardStack> *stacks;
	EstateList *estates;

	TQComboBox *cards;
	CardView *view;
	TQVBoxLayout *vlayout;
};

class StreetDlg : public EstateDlg
{
	Q_OBJECT

	public:
	StreetDlg(ConfigEstateGroupList *, TQWidget *parent = 0, char *name = 0);

	protected:
	virtual void save();
	virtual void update();
	virtual void groupUpdate();

	private slots:
	void groupChanged(const TQString &);

	private:
	TQSpinBox *houses0;
	TQSpinBox *houses1;
	TQSpinBox *houses2;
	TQSpinBox *houses3;
	TQSpinBox *houses4;
	TQSpinBox *houses5;
	TQSpinBox *price;
	KComboBox *groupCombo;

	ConfigEstateGroupList *groups;

	ConfigEstateGroup *curGroup();
};

#endif