author | rubidium |
Tue, 06 May 2008 22:08:18 +0000 | |
changeset 9116 | f2491d3c321b |
parent 9111 | 48ce04029fe4 |
child 9142 | 858a058aa730 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8965
diff
changeset
|
3 |
/** @file cheat_gui.cpp GUI related to cheating. */ |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1879
diff
changeset
|
6 |
#include "openttd.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
7 |
#include "command_func.h" |
8965
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
8 |
#include "cheat_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
9 |
#include "player_base.h" |
8965
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
10 |
#include "player_func.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
11 |
#include "gfx_func.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
12 |
#include "date_func.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
13 |
#include "saveload.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
14 |
#include "window_gui.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
15 |
#include "newgrf.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
16 |
#include "settings_type.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8108
diff
changeset
|
17 |
#include "strings_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8123
diff
changeset
|
18 |
#include "window_func.h" |
8809
e0d09d74e805
(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents:
8787
diff
changeset
|
19 |
#include "rail_gui.h" |
8965
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
20 |
#include "gui.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
21 |
#include "player_gui.h" |
911
7ccc33888a33
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
22 |
|
8965
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
23 |
#include "table/strings.h" |
29a591456a2f
(svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents:
8916
diff
changeset
|
24 |
#include "table/sprites.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
25 |
|
0 | 26 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
27 |
/** |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
28 |
* The 'amount' to cheat with. |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
29 |
* This variable is semantically a constant value, but because the cheat |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
30 |
* code requires to be able to write to the variable it is not constified. |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
31 |
*/ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
32 |
static int32 _money_cheat_amount = 10000000; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
33 |
|
410 | 34 |
static int32 ClickMoneyCheat(int32 p1, int32 p2) |
0 | 35 |
{ |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
36 |
DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, NULL, CMD_MONEY_CHEAT); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
37 |
return _money_cheat_amount; |
0 | 38 |
} |
39 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
40 |
/** |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
41 |
* @param p1 player to set to |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
42 |
* @param p2 is -1 or +1 (down/up) |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
43 |
*/ |
410 | 44 |
static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
0 | 45 |
{ |
4850
93095755db8c
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4834
diff
changeset
|
46 |
while (IsValidPlayer((PlayerID)p1)) { |
2639 | 47 |
if (_players[p1].is_active) { |
5376
204acb84473f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5355
diff
changeset
|
48 |
SetLocalPlayer((PlayerID)p1); |
204acb84473f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5355
diff
changeset
|
49 |
|
138
6ab4d97d1034
(svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents:
108
diff
changeset
|
50 |
MarkWholeScreenDirty(); |
0 | 51 |
return _local_player; |
52 |
} |
|
53 |
p1 += p2; |
|
54 |
} |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
55 |
|
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
56 |
return _local_player; |
0 | 57 |
} |
58 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
59 |
/** |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
60 |
* @param p1 -1 or +1 (down/up) |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
61 |
* @param p2 unused |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
62 |
*/ |
1095 | 63 |
static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
100 | 64 |
{ |
2639 | 65 |
if (p1 == -1) p1 = 3; |
66 |
if (p1 == 4) p1 = 0; |
|
100 | 67 |
_opt.landscape = p1; |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
68 |
ReloadNewGRFData(); |
100 | 69 |
return _opt.landscape; |
70 |
} |
|
71 |
||
6247 | 72 |
extern void EnginesMonthlyLoop(); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
73 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
74 |
/** |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
75 |
* @param p1 unused |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
76 |
* @param p2 1 (increase) or -1 (decrease) |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
77 |
*/ |
1095 | 78 |
static int32 ClickChangeDateCheat(int32 p1, int32 p2) |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
79 |
{ |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
80 |
YearMonthDay ymd; |
4288
393de75451b1
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
81 |
ConvertDateToYMD(_date, &ymd); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
82 |
|
4293
4b7006c1b5eb
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
83 |
if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year; |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
84 |
|
4288
393de75451b1
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
85 |
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
86 |
EnginesMonthlyLoop(); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
87 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
8809
e0d09d74e805
(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents:
8787
diff
changeset
|
88 |
ResetSignalVariant(); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
89 |
return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
90 |
} |
100 | 91 |
|
0 | 92 |
typedef int32 CheckButtonClick(int32, int32); |
93 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
94 |
struct CheatEntry { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
95 |
VarType type; ///< type of selector |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
96 |
StringID str; ///< string with descriptive text |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
97 |
void *variable; ///< pointer to the variable |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
98 |
bool *been_used; ///< has this cheat been used before? |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
99 |
CheckButtonClick *proc;///< procedure |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
100 |
}; |
0 | 101 |
|
102 |
static const CheatEntry _cheats_ui[] = { |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
103 |
{SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
104 |
{SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
105 |
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
106 |
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
107 |
{SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
108 |
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
109 |
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
110 |
{SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat}, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
111 |
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat }, |
0 | 112 |
}; |
113 |
||
114 |
||
115 |
static const Widget _cheat_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
116 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
117 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
118 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
119 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
172
diff
changeset
|
120 |
{ WIDGETS_END}, |
0 | 121 |
}; |
122 |
||
123 |
static void CheatsWndProc(Window *w, WindowEvent *e) |
|
124 |
{ |
|
2639 | 125 |
switch (e->event) { |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
126 |
case WE_PAINT: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
127 |
int clk = WP(w, def_d).data_1; |
2639 | 128 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
129 |
DrawWindowWidgets(w); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
130 |
DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50); |
3110
53cc5f8754aa
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
131 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
132 |
for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
133 |
const CheatEntry *ce = &_cheats_ui[i]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
134 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
135 |
DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, x + 5, y + 2); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
136 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
137 |
switch (ce->type) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
138 |
case SLE_BOOL: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
139 |
bool on = (*(bool*)ce->variable); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
140 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
141 |
DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, on ? 6 : 4, on ? FR_LOWERED : FR_NONE); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
142 |
SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
143 |
} break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
144 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
145 |
default: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
146 |
int32 val = (int32)ReadValue(ce->variable, ce->type); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
147 |
char buf[512]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
148 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
149 |
/* Draw [<][>] boxes for settings of an integer-type */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
150 |
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
151 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
152 |
switch (ce->str) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
153 |
/* Display date for change date cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
154 |
case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
155 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
156 |
/* Draw colored flag for change player cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
157 |
case STR_CHEAT_CHANGE_PLAYER: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
158 |
SetDParam(0, val); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
159 |
GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf)); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
160 |
DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
161 |
break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
162 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
163 |
/* Set correct string for switch climate cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
164 |
case STR_CHEAT_SWITCH_CLIMATE: val += STR_TEMPERATE_LANDSCAPE; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
165 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
166 |
/* Fallthrough */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
167 |
default: SetDParam(0, val); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
168 |
} |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
169 |
} break; |
2639 | 170 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
171 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
172 |
DrawString(50, y + 1, ce->str, TC_FROMSTRING); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
173 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
174 |
y += 12; |
0 | 175 |
} |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
176 |
break; |
0 | 177 |
} |
2639 | 178 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
179 |
case WE_CLICK: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
180 |
uint btn = (e->we.click.pt.y - 46) / 12; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
181 |
uint x = e->we.click.pt.x; |
0 | 182 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
183 |
/* Not clicking a button? */ |
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7931
diff
changeset
|
184 |
if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) break; |
0 | 185 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
186 |
const CheatEntry *ce = &_cheats_ui[btn]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
187 |
int value = (int32)ReadValue(ce->variable, ce->type); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
188 |
int oldvalue = value; |
0 | 189 |
|
190 |
*ce->been_used = true; |
|
191 |
||
2639 | 192 |
switch (ce->type) { |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
193 |
case SLE_BOOL: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
194 |
value ^= 1; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
195 |
if (ce->proc != NULL) ce->proc(value, 0); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
196 |
break; |
0 | 197 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
198 |
default: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
199 |
/* Take whatever the function returns */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
200 |
value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1); |
0 | 201 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
202 |
if (value != oldvalue) WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
203 |
break; |
0 | 204 |
} |
205 |
||
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
206 |
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value); |
0 | 207 |
|
208 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
209 |
||
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
210 |
w->SetDirty(); |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
211 |
} break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
212 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
213 |
case WE_TIMEOUT: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
214 |
WP(w, def_d).data_1 = 0; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
215 |
w->SetDirty(); |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
216 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
217 |
} |
0 | 218 |
} |
2639 | 219 |
|
0 | 220 |
static const WindowDesc _cheats_desc = { |
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
221 |
240, 22, 400, 170, 400, 170, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
222 |
WC_CHEATS, WC_NONE, |
0 | 223 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
224 |
_cheat_widgets, |
|
225 |
CheatsWndProc |
|
226 |
}; |
|
227 |
||
228 |
||
6247 | 229 |
void ShowCheatWindow() |
0 | 230 |
{ |
231 |
DeleteWindowById(WC_CHEATS, 0); |
|
5137
54425dc8b5b3
(svn r7219) -Fix: Several warnings by gcc introduced in r7206 which MSVC found not of a problem. Thanks Tron
Darkvater
parents:
5125
diff
changeset
|
232 |
AllocateWindowDesc(&_cheats_desc); |
0 | 233 |
} |