author | bjarni |
Sun, 02 Jan 2005 17:23:04 +0000 | |
changeset 842 | ebfd36603ab9 |
parent 835 | a22d6bc16a51 |
child 867 | 581154a08a78 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
502
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "command.h" |
|
8 |
#include "engine.h" |
|
430 | 9 |
#include "screenshot.h" |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
10 |
#include "newgrf.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
11 |
#include "network.h" |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
12 |
#include "console.h" |
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
13 |
#include "town.h" |
0 | 14 |
|
15 |
static uint32 _difficulty_click_a; |
|
16 |
static uint32 _difficulty_click_b; |
|
17 |
static byte _difficulty_timeout; |
|
18 |
||
19 |
extern const StringID _currency_string_list[]; |
|
20 |
extern uint GetMaskOfAllowedCurrencies(); |
|
21 |
||
22 |
static const StringID _distances_dropdown[] = { |
|
23 |
STR_0139_IMPERIAL_MILES, |
|
24 |
STR_013A_METRIC_KILOMETERS, |
|
25 |
INVALID_STRING_ID |
|
26 |
}; |
|
27 |
||
28 |
static const StringID _driveside_dropdown[] = { |
|
29 |
STR_02E9_DRIVE_ON_LEFT, |
|
30 |
STR_02EA_DRIVE_ON_RIGHT, |
|
31 |
INVALID_STRING_ID |
|
32 |
}; |
|
33 |
||
34 |
static const StringID _autosave_dropdown[] = { |
|
35 |
STR_02F7_OFF, |
|
36 |
STR_AUTOSAVE_1_MONTH, |
|
37 |
STR_02F8_EVERY_3_MONTHS, |
|
38 |
STR_02F9_EVERY_6_MONTHS, |
|
39 |
STR_02FA_EVERY_12_MONTHS, |
|
40 |
INVALID_STRING_ID, |
|
41 |
}; |
|
42 |
||
43 |
static const StringID _designnames_dropdown[] = { |
|
44 |
STR_02BE_DEFAULT, |
|
45 |
STR_02BF_CUSTOM, |
|
46 |
INVALID_STRING_ID |
|
47 |
}; |
|
48 |
||
49 |
static StringID *BuildDynamicDropdown(StringID base, int num) |
|
50 |
{ |
|
51 |
static StringID buf[32 + 1]; |
|
52 |
StringID *p = buf; |
|
53 |
while (--num>=0) *p++ = base++; |
|
54 |
*p = INVALID_STRING_ID; |
|
55 |
return buf; |
|
56 |
} |
|
57 |
||
58 |
static int GetCurRes() |
|
59 |
{ |
|
60 |
int i; |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
61 |
for(i = 0; i != _num_resolutions; i++) |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
62 |
if (_resolutions[i][0] == _screen.width && |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
63 |
_resolutions[i][1] == _screen.height) |
0 | 64 |
break; |
65 |
return i; |
|
66 |
} |
|
67 |
||
68 |
static void GameOptionsWndProc(Window *w, WindowEvent *e) |
|
69 |
{ |
|
70 |
int i; |
|
71 |
||
72 |
switch(e->event) { |
|
73 |
case WE_PAINT: { |
|
74 |
StringID str = STR_02BE_DEFAULT; |
|
75 |
w->disabled_state = (_vehicle_design_names & 1) ? (++str, 0) : (1 << 21); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
76 |
SetDParam(0, str); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
77 |
SetDParam(1, _currency_string_list[_opt_mod_ptr->currency]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
78 |
SetDParam(2, _opt_mod_ptr->kilometers + STR_0139_IMPERIAL_MILES); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
79 |
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_mod_ptr->road_side); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
812
diff
changeset
|
80 |
SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_mod_ptr->town_name); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
81 |
SetDParam(5, _autosave_dropdown[_opt_mod_ptr->autosave]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
82 |
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr); |
0 | 83 |
i = GetCurRes(); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
84 |
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
85 |
SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
86 |
(_fullscreen) ? SETBIT(w->click_state, 28) : CLRBIT(w->click_state, 28); // fullscreen button |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
87 |
|
0 | 88 |
DrawWindowWidgets(w); |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
89 |
DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen |
0 | 90 |
} break; |
91 |
||
92 |
case WE_CLICK: |
|
93 |
switch(e->click.widget) { |
|
94 |
case 5: |
|
842 | 95 |
ShowDropDownMenu(w, _currency_string_list, _opt_mod_ptr->currency, e->click.widget, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0); |
0 | 96 |
return; |
97 |
case 8: |
|
842 | 98 |
ShowDropDownMenu(w, _distances_dropdown, _opt_mod_ptr->kilometers, e->click.widget, 0, 0); |
0 | 99 |
return; |
100 |
case 11: { |
|
101 |
int i = _opt_mod_ptr->road_side; |
|
842 | 102 |
ShowDropDownMenu(w, _driveside_dropdown, i, e->click.widget, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0); |
0 | 103 |
return; |
104 |
} |
|
105 |
case 14: { |
|
106 |
int i = _opt_mod_ptr->town_name; |
|
842 | 107 |
ShowDropDownMenu(w, BuildDynamicDropdown(STR_TOWNNAME_ORIGINAL_ENGLISH, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1), i, e->click.widget, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0); |
0 | 108 |
return; |
109 |
} |
|
110 |
case 17: |
|
842 | 111 |
ShowDropDownMenu(w, _autosave_dropdown, _opt_mod_ptr->autosave, e->click.widget, 0, 0); |
0 | 112 |
return; |
113 |
case 20: |
|
842 | 114 |
ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names&1)?1:0, e->click.widget, (_vehicle_design_names&2)?0:2, 0); |
0 | 115 |
return; |
116 |
case 21: |
|
117 |
return; |
|
118 |
case 24: |
|
842 | 119 |
ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, e->click.widget, 0, 0); |
0 | 120 |
return; |
121 |
case 27: |
|
122 |
// setup resolution dropdown |
|
842 | 123 |
ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), e->click.widget, 0, 0); |
0 | 124 |
return; |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
125 |
case 28: /* Click fullscreen on/off */ |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
126 |
(_fullscreen) ? CLRBIT(w->click_state, 28) : SETBIT(w->click_state, 28); |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
127 |
ToggleFullScreen(!_fullscreen); // toggle full-screen on/off |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
128 |
SetWindowDirty(w); |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
129 |
return; |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
130 |
case 31: /* Setup screenshot format dropdown */ |
842 | 131 |
ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, e->click.widget, 0, 0); |
0 | 132 |
return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
133 |
|
0 | 134 |
} |
135 |
break; |
|
136 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
137 |
case WE_DROPDOWN_SELECT: |
0 | 138 |
switch(e->dropdown.button) { |
139 |
case 20: |
|
140 |
if (e->dropdown.index == 0) { |
|
141 |
DeleteCustomEngineNames(); |
|
142 |
MarkWholeScreenDirty(); |
|
143 |
} else if (!(_vehicle_design_names&1)) { |
|
144 |
LoadCustomEngineNames(); |
|
145 |
MarkWholeScreenDirty(); |
|
146 |
} |
|
147 |
break; |
|
148 |
case 5: |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
149 |
if (e->dropdown.index == 23) |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
150 |
ShowCustCurrency(); |
0 | 151 |
_opt_mod_ptr->currency = _opt.currency = e->dropdown.index; |
152 |
MarkWholeScreenDirty(); |
|
153 |
break; |
|
154 |
case 8: |
|
155 |
_opt_mod_ptr->kilometers = e->dropdown.index; |
|
156 |
MarkWholeScreenDirty(); |
|
157 |
break; |
|
158 |
case 11: |
|
159 |
if (_game_mode == GM_MENU) |
|
160 |
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_EMPTY)); |
|
161 |
break; |
|
162 |
case 14: |
|
163 |
if (_game_mode == GM_MENU) |
|
164 |
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_TOWN_NAME_TYPE | CMD_MSG(STR_EMPTY)); |
|
165 |
break; |
|
166 |
case 17: |
|
167 |
_opt_mod_ptr->autosave = e->dropdown.index; |
|
168 |
SetWindowDirty(w); |
|
169 |
break; |
|
170 |
||
171 |
// change interface language |
|
172 |
case 24: |
|
173 |
ReadLanguagePack(e->dropdown.index); |
|
174 |
MarkWholeScreenDirty(); |
|
175 |
break; |
|
176 |
||
177 |
// change resolution |
|
178 |
case 27: |
|
179 |
if (e->dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->dropdown.index][0],_resolutions[e->dropdown.index][1])) |
|
180 |
SetWindowDirty(w); |
|
181 |
break; |
|
182 |
||
183 |
// change screenshot format |
|
315
e008762a8689
(svn r321) -Fix: crash when making png screenshot with odd resolution (Tron)
truelight
parents:
306
diff
changeset
|
184 |
case 31: |
0 | 185 |
SetScreenshotFormat(e->dropdown.index); |
186 |
SetWindowDirty(w); |
|
187 |
break; |
|
188 |
} |
|
189 |
break; |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
190 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
191 |
case WE_DESTROY: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
192 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
193 |
break; |
0 | 194 |
} |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
195 |
|
0 | 196 |
} |
197 |
||
198 |
int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
199 |
{ |
|
200 |
if (flags & DC_EXEC) { |
|
201 |
_opt_mod_ptr->road_side = p1; |
|
202 |
InvalidateWindow(WC_GAME_OPTIONS,0); |
|
203 |
} |
|
204 |
return 0; |
|
205 |
} |
|
206 |
||
207 |
int32 CmdSetTownNameType(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
208 |
{ |
|
209 |
if (flags & DC_EXEC) { |
|
210 |
_opt_mod_ptr->town_name = p1; |
|
211 |
InvalidateWindow(WC_GAME_OPTIONS,0); |
|
212 |
} |
|
213 |
return 0; |
|
214 |
} |
|
215 |
||
216 |
||
217 |
static const Widget _game_options_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
218 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
219 |
{ WWT_CAPTION, 14, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
220 |
{ WWT_PANEL, 14, 0, 369, 14, 238, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
221 |
{ WWT_FRAME, 14, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
222 |
{ WWT_6, 14, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
223 |
{ WWT_CLOSEBOX, 14, 158, 168, 35, 44, STR_0225, STR_02E2_CURRENCY_UNITS_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
224 |
{ WWT_FRAME, 14, 190, 359, 20, 55, STR_02E3_DISTANCE_UNITS, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
225 |
{ WWT_6, 14, 200, 349, 34, 45, STR_02E4, STR_02E5_DISTANCE_UNITS_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
226 |
{ WWT_CLOSEBOX, 14, 338, 348, 35, 44, STR_0225, STR_02E5_DISTANCE_UNITS_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
227 |
{ WWT_FRAME, 14, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
228 |
{ WWT_6, 14, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
229 |
{ WWT_CLOSEBOX, 14, 158, 168, 77, 86, STR_0225, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
230 |
{ WWT_FRAME, 14, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
231 |
{ WWT_6, 14, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
232 |
{ WWT_CLOSEBOX, 14, 338, 348, 77, 86, STR_0225, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
233 |
{ WWT_FRAME, 14, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
234 |
{ WWT_6, 14, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
235 |
{ WWT_CLOSEBOX, 14, 158, 168, 119, 128, STR_0225, STR_02F6_SELECT_INTERVAL_BETWEEN}, |
0 | 236 |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
237 |
{ WWT_FRAME, 14, 10, 359, 194, 228, STR_02BC_VEHICLE_DESIGN_NAMES, STR_NULL}, |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
238 |
{ WWT_6, 14, 20, 119, 207, 218, STR_02BD, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
239 |
{ WWT_CLOSEBOX, 14, 108, 118, 208, 217, STR_0225, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, |
654
48d737ea744c
(svn r1088) Strings cleanup. Renamed some strings to reflect their content.
dominik
parents:
639
diff
changeset
|
240 |
{ WWT_CLOSEBOX, 14, 130, 349, 207, 218, STR_02C0_SAVE_CUSTOM_NAMES, STR_02C2_SAVE_CUSTOMIZED_VEHICLE}, |
0 | 241 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
242 |
{ WWT_FRAME, 14, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
243 |
{ WWT_6, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
244 |
{ WWT_CLOSEBOX, 14, 338, 348, 119, 128, STR_0225, STR_OPTIONS_LANG_TIP}, |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
245 |
|
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
246 |
{ WWT_FRAME, 14, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
247 |
{ WWT_6, 14, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
248 |
{ WWT_CLOSEBOX, 14, 158, 168, 161, 170, STR_0225, STR_OPTIONS_RES_TIP}, |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
249 |
{ WWT_TEXTBTN, 14, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, |
0 | 250 |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
251 |
{ WWT_FRAME, 14, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, |
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
252 |
{ WWT_6, 14, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
253 |
{ WWT_CLOSEBOX, 14, 338, 348, 161, 170, STR_0225, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, |
0 | 254 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
255 |
{ WIDGETS_END}, |
0 | 256 |
}; |
257 |
||
258 |
static const WindowDesc _game_options_desc = { |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
259 |
WDP_CENTER, WDP_CENTER, 370, 239, |
0 | 260 |
WC_GAME_OPTIONS,0, |
261 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS, |
|
262 |
_game_options_widgets, |
|
263 |
GameOptionsWndProc |
|
264 |
}; |
|
265 |
||
266 |
||
267 |
void ShowGameOptions() |
|
268 |
{ |
|
269 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
270 |
AllocateWindowDesc(&_game_options_desc); |
|
271 |
} |
|
272 |
||
273 |
typedef struct { |
|
274 |
int16 min; |
|
275 |
int16 max; |
|
276 |
int16 step; |
|
277 |
StringID str; |
|
278 |
} GameSettingData; |
|
279 |
||
280 |
static const GameSettingData _game_setting_info[] = { |
|
281 |
{0,7,1,0}, |
|
282 |
{0,3,1,STR_6830_IMMEDIATE}, |
|
283 |
{0,2,1,STR_6816_LOW}, |
|
61
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
58
diff
changeset
|
284 |
{0,3,1,STR_26816_NONE}, |
0 | 285 |
{100,500,50,0}, |
286 |
{2,4,1,0}, |
|
287 |
{0,2,1,STR_6820_LOW}, |
|
288 |
{0,4,1,STR_681B_VERY_SLOW}, |
|
289 |
{0,2,1,STR_6820_LOW}, |
|
290 |
{0,2,1,STR_6823_NONE}, |
|
291 |
{0,3,1,STR_6826_X1_5}, |
|
292 |
{0,2,1,STR_6820_LOW}, |
|
293 |
{0,3,1,STR_682A_VERY_FLAT}, |
|
294 |
{0,3,1,STR_VERY_LOW}, |
|
295 |
{0,1,1,STR_682E_STEADY}, |
|
296 |
{0,1,1,STR_6834_AT_END_OF_LINE_AND_AT_STATIONS}, |
|
297 |
{0,1,1,STR_6836_OFF}, |
|
298 |
{0,2,1,STR_6839_PERMISSIVE}, |
|
299 |
}; |
|
300 |
||
536 | 301 |
static inline bool GetBitAndShift(uint32 *b) |
0 | 302 |
{ |
303 |
uint32 x = *b; |
|
304 |
*b >>= 1; |
|
305 |
return (x&1) != 0; |
|
306 |
} |
|
307 |
||
308 |
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { |
|
61
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
58
diff
changeset
|
309 |
{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, |
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
58
diff
changeset
|
310 |
{4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, |
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
58
diff
changeset
|
311 |
{7, 0, 2, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, |
0 | 312 |
}; |
313 |
||
314 |
void SetDifficultyLevel(int mode, GameOptions *gm_opt) |
|
315 |
{ |
|
316 |
int i; |
|
317 |
assert(mode <= 3); |
|
318 |
||
319 |
gm_opt->diff_level = mode; |
|
320 |
if (mode != 3) { // not custom |
|
321 |
for(i = 0; i != GAME_DIFFICULTY_NUM; i++) |
|
322 |
((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i]; |
|
323 |
} |
|
324 |
} |
|
325 |
||
46
c9bdf1d58df6
(svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents:
42
diff
changeset
|
326 |
extern void StartupEconomy(); |
c9bdf1d58df6
(svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents:
42
diff
changeset
|
327 |
|
0 | 328 |
static void GameDifficultyWndProc(Window *w, WindowEvent *e) |
329 |
{ |
|
330 |
switch(e->event) { |
|
331 |
case WE_PAINT: { |
|
332 |
uint32 click_a, click_b, disabled; |
|
333 |
int i; |
|
334 |
int x,y,value; |
|
335 |
||
336 |
w->click_state = (1 << 4) << _opt_mod_temp.diff_level; |
|
337 |
w->disabled_state = (_game_mode != GM_NORMAL) ? 0 : (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
338 |
// Disable save-button in multiplayer (and if client) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
339 |
if (_networking && !_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
340 |
w->disabled_state |= (1 << 10); |
0 | 341 |
DrawWindowWidgets(w); |
342 |
||
343 |
click_a = _difficulty_click_a; |
|
344 |
click_b = _difficulty_click_b; |
|
345 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
346 |
/* XXX - This is most likely the worst way I have ever seen |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
347 |
to disable some buttons and to enable others. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
348 |
What the value means, is this: |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
349 |
if bit1 is enabled, setting 1 is disabled |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
350 |
then it is shifted to the left, and the story |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
351 |
repeats.... |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
352 |
-- TrueLight */ |
0 | 353 |
disabled = _game_mode == GM_NORMAL ? 0x383E : 0; |
354 |
||
355 |
x = 0; |
|
356 |
y = 32; |
|
357 |
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) { |
|
358 |
DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, GetBitAndShift(&click_a)?0x20:0); |
|
359 |
DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, GetBitAndShift(&click_b)?0x20:0); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
360 |
if (GetBitAndShift(&disabled) || (_networking && !_network_server)) { |
0 | 361 |
int color = 0x8000 | _color_list[3].unk2; |
362 |
GfxFillRect(x+6, y+2, x+6+8, y+9, color); |
|
363 |
GfxFillRect(x+16, y+2, x+16+8, y+9, color); |
|
364 |
} |
|
365 |
||
366 |
DrawStringCentered(x+10, y+1, STR_6819, 0); |
|
367 |
DrawStringCentered(x+20, y+1, STR_681A, 0); |
|
368 |
||
369 |
||
370 |
value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i]; |
|
371 |
if (i == 4) value *= 1000; // handle currency option |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
372 |
SetDParam(0, value); |
0 | 373 |
DrawString(x+30, y+1, STR_6805_MAXIMUM_NO_COMPETITORS + i, 0); |
374 |
||
375 |
y += 11; |
|
376 |
} |
|
377 |
} break; |
|
378 |
||
379 |
case WE_CLICK: |
|
380 |
switch(e->click.widget) { |
|
381 |
case 3: { |
|
382 |
int x,y; |
|
383 |
uint btn, dis; |
|
384 |
int val; |
|
385 |
const GameSettingData *info; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
386 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
387 |
// Don't allow clients to make any changes |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
388 |
if (_networking && !_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
389 |
return; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
390 |
|
0 | 391 |
x = e->click.pt.x - 5; |
392 |
if (!IS_INT_INSIDE(x, 0, 21)) |
|
393 |
return; |
|
394 |
||
395 |
y = e->click.pt.y - 33; |
|
396 |
if (y < 0) |
|
397 |
return; |
|
398 |
||
399 |
// Get button from Y coord. |
|
400 |
btn = y / 11; |
|
401 |
if (btn >= GAME_DIFFICULTY_NUM || y % 11 > 9) |
|
402 |
return; |
|
403 |
||
404 |
// Clicked disabled button? |
|
405 |
dis = 0; |
|
406 |
if (_game_mode == GM_NORMAL) |
|
407 |
dis |= 0x383E; |
|
408 |
if (HASBIT(dis, btn)) |
|
409 |
return; |
|
410 |
||
411 |
_difficulty_timeout = 5; |
|
412 |
||
413 |
val = ((int*)&_opt_mod_temp.diff)[btn]; |
|
414 |
||
415 |
info = &_game_setting_info[btn]; |
|
416 |
if (x >= 10) { |
|
417 |
// Increase button clicked |
|
418 |
val = min(val + info->step, info->max); |
|
419 |
SETBIT(_difficulty_click_b, btn); |
|
420 |
} else { |
|
421 |
// Decrease button clicked |
|
422 |
val = max(val - info->step, info->min); |
|
423 |
SETBIT(_difficulty_click_a, btn); |
|
424 |
} |
|
425 |
||
426 |
// save value in temporary variable |
|
427 |
((int*)&_opt_mod_temp.diff)[btn] = val; |
|
428 |
SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom |
|
429 |
SetWindowDirty(w); |
|
430 |
break; |
|
431 |
} |
|
432 |
case 4: case 5: case 6: case 7: // easy/medium/hard/custom |
|
433 |
// temporarily change difficulty level |
|
434 |
SetDifficultyLevel(e->click.widget - 4, &_opt_mod_temp); |
|
435 |
SetWindowDirty(w); |
|
436 |
break; |
|
437 |
case 8: |
|
438 |
ShowHighscoreTable(_opt_mod_ptr->diff_level); |
|
439 |
break; |
|
440 |
case 10: { // Save button - save changes |
|
441 |
int btn, val; |
|
442 |
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) { |
|
443 |
val = ((int*)&_opt_mod_temp.diff)[btn]; |
|
444 |
// if setting has changed, change it |
|
445 |
if (val != ((int*)&_opt_mod_ptr->diff)[btn]) |
|
446 |
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
447 |
} |
|
448 |
DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
449 |
DeleteWindow(w); |
|
42
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
450 |
// If we are in the editor, we should reload the economy. |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
451 |
// This way when you load a game, the max loan and interest rate |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
452 |
// are loaded correctly. |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
453 |
if (_game_mode == GM_EDITOR) |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
454 |
StartupEconomy(); |
0 | 455 |
break; |
456 |
} |
|
457 |
case 11: // Cancel button - close window |
|
458 |
DeleteWindow(w); |
|
459 |
break; |
|
460 |
} |
|
461 |
break; |
|
462 |
||
463 |
case WE_MOUSELOOP: |
|
464 |
if (_difficulty_timeout != 0 && !--_difficulty_timeout) { |
|
465 |
_difficulty_click_a = 0; |
|
466 |
_difficulty_click_b = 0; |
|
467 |
SetWindowDirty(w); |
|
468 |
} |
|
469 |
break; |
|
470 |
} |
|
471 |
} |
|
472 |
||
473 |
static const Widget _game_difficulty_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
474 |
{ WWT_CLOSEBOX, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
475 |
{ WWT_CAPTION, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
476 |
{ WWT_PANEL, 10, 0, 369, 14, 29, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
477 |
{ WWT_PANEL, 10, 0, 369, 30, 276, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
478 |
{ WWT_PUSHTXTBTN, 3, 10, 96, 16, 27, STR_6801_EASY, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
479 |
{ WWT_PUSHTXTBTN, 3, 97, 183, 16, 27, STR_6802_MEDIUM, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
480 |
{ WWT_PUSHTXTBTN, 3, 184, 270, 16, 27, STR_6803_HARD, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
481 |
{ WWT_PUSHTXTBTN, 3, 271, 357, 16, 27, STR_6804_CUSTOM, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
482 |
{ WWT_EMPTY, 10, 0, 369, 251, 262, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
483 |
//{ WWT_CLOSEBOX, 10, 0, 369, 251, 262, STR_6838_SHOW_HI_SCORE_CHART,STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
484 |
{ WWT_PANEL, 10, 0, 369, 263, 278, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
485 |
{ WWT_PUSHTXTBTN, 3, 105, 185, 265, 276, STR_OPTIONS_SAVE_CHANGES, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
486 |
{ WWT_PUSHTXTBTN, 3, 186, 266, 265, 276, STR_012E_CANCEL, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
487 |
{ WIDGETS_END}, |
0 | 488 |
}; |
489 |
||
490 |
static const WindowDesc _game_difficulty_desc = { |
|
491 |
WDP_CENTER, WDP_CENTER, 370, 279, |
|
492 |
WC_GAME_OPTIONS,0, |
|
493 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
494 |
_game_difficulty_widgets, |
|
495 |
GameDifficultyWndProc |
|
496 |
}; |
|
497 |
||
498 |
void ShowGameDifficulty() |
|
499 |
{ |
|
500 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
501 |
/* copy current settings to temporary holding place |
|
502 |
* change that when setting stuff, copy back on clicking 'OK' |
|
503 |
*/ |
|
504 |
memcpy(&_opt_mod_temp, _opt_mod_ptr, sizeof(GameOptions)); |
|
505 |
AllocateWindowDesc(&_game_difficulty_desc); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
506 |
} |
0 | 507 |
|
508 |
void ShowHighscoreTable(int tbl) |
|
509 |
{ |
|
510 |
ShowInfoF("ShowHighscoreTable(%d) not implemented", tbl); |
|
511 |
} |
|
512 |
||
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
513 |
// virtual PositionMainToolbar function, calls the right one. |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
514 |
int32 v_PositionMainToolbar(int32 p1) |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
515 |
{ |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
516 |
if (_game_mode != GM_MENU) |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
517 |
PositionMainToolbar(NULL); |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
518 |
|
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
519 |
return 0; |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
520 |
} |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
521 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
68
diff
changeset
|
522 |
int32 AiNew_PatchActive_Warning(int32 p1) |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
68
diff
changeset
|
523 |
{ |
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
91
diff
changeset
|
524 |
if (p1 == 1) |
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
91
diff
changeset
|
525 |
ShowErrorMessage(-1, TEMP_AI_ACTIVATED, 0, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
526 |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
91
diff
changeset
|
527 |
return 0; |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
68
diff
changeset
|
528 |
} |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
68
diff
changeset
|
529 |
|
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
530 |
int32 PopulationInLabelActive(int32 p1) |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
531 |
{ |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
532 |
Town *t; |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
533 |
|
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
534 |
FOR_ALL_TOWNS(t) { |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
535 |
if (t->xy) { |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
536 |
UpdateTownVirtCoord(t); |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
537 |
} |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
538 |
} |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
539 |
|
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
540 |
return 0; |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
541 |
} |
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
542 |
|
91
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
543 |
int32 InvisibleTreesActive(int32 p1) |
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
544 |
{ |
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
545 |
MarkWholeScreenDirty(); |
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
546 |
return 0; |
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
547 |
} |
6477ea0c240d
(svn r92) Feature: invisible trees when in transparent mode (patch entry)
dominik
parents:
84
diff
changeset
|
548 |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
549 |
int32 InValidateDetailsWindow(int32 p1) |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
550 |
{ |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
551 |
InvalidateWindowClasses(WC_VEHICLE_DETAILS); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
552 |
return 0; |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
553 |
} |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
554 |
|
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
555 |
/* Check service intervals of vehicles, p1 is value of % or day based servicing */ |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
556 |
int32 CheckInterval(int32 p1) |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
557 |
{ |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
558 |
bool warning; |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
559 |
if (p1) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
560 |
warning = ( (IS_INT_INSIDE(_patches.servint_trains, 5, 90+1) || _patches.servint_trains == 0) && |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
561 |
(IS_INT_INSIDE(_patches.servint_roadveh, 5, 90+1) || _patches.servint_roadveh == 0) && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
562 |
(IS_INT_INSIDE(_patches.servint_aircraft, 5, 90+1) || _patches.servint_aircraft == 0) && |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
563 |
(IS_INT_INSIDE(_patches.servint_ships, 5, 90+1) || _patches.servint_ships == 0) ); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
564 |
} else { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
565 |
warning = ( (IS_INT_INSIDE(_patches.servint_trains, 30, 800+1) || _patches.servint_trains == 0) && |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
566 |
(IS_INT_INSIDE(_patches.servint_roadveh, 30, 800+1) || _patches.servint_roadveh == 0) && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
567 |
(IS_INT_INSIDE(_patches.servint_aircraft, 30, 800+1) || _patches.servint_aircraft == 0) && |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
568 |
(IS_INT_INSIDE(_patches.servint_ships, 30, 800+1) || _patches.servint_ships == 0) ); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
569 |
} |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
570 |
|
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
571 |
if (!warning) |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
572 |
ShowErrorMessage(-1, STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE, 0, 0); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
573 |
|
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
574 |
return InValidateDetailsWindow(0); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
575 |
} |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
155
diff
changeset
|
576 |
|
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
577 |
typedef int32 PatchButtonClick(int32); |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
578 |
|
0 | 579 |
typedef struct PatchEntry { |
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
580 |
byte type; // type of selector |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
581 |
byte flags; // selector flags |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
582 |
StringID str; // string with descriptive text |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
583 |
char console_name[40]; // the name this patch has in console |
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
584 |
void *variable; // pointer to the variable |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
585 |
int32 min,max; // range for spinbox setting |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
586 |
uint32 step; // step for spinbox |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
587 |
PatchButtonClick *click_proc; // callback procedure |
0 | 588 |
} PatchEntry; |
589 |
||
590 |
enum { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
591 |
PE_BOOL = 0, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
592 |
PE_UINT8 = 1, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
593 |
PE_INT16 = 2, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
594 |
PE_UINT16 = 3, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
595 |
PE_INT32 = 4, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
596 |
PE_CURRENCY = 5, |
0 | 597 |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
598 |
PF_0ISDIS = 1, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
599 |
PF_NOCOMMA = 2, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
600 |
PF_MULTISTRING = 4, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
601 |
PF_PLAYERBASED = 8, // This has to match the entries that are in settings.c, patch_player_settings |
0 | 602 |
}; |
603 |
||
604 |
static const PatchEntry _patches_ui[] = { |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
605 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_VEHICLESPEED, "vehicle_speed", &_patches.vehicle_speed, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
606 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_LONGDATE, "long_date", &_patches.status_long_date, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
607 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_SHOWFINANCES, "show_finances", &_patches.show_finances, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
608 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTOSCROLL, "autoscroll", &_patches.autoscroll, 0, 0, 0, NULL}, |
0 | 609 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
610 |
{PE_UINT8, PF_PLAYERBASED, STR_CONFIG_PATCHES_ERRMSG_DURATION, "errmsg_duration", &_patches.errmsg_duration, 0, 20, 1, NULL}, |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
611 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
612 |
{PE_UINT8, PF_MULTISTRING | PF_PLAYERBASED, STR_CONFIG_PATCHES_TOOLBAR_POS, "toolbar_pos", &_patches.toolbar_pos, 0, 2, 1, &v_PositionMainToolbar}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
613 |
{PE_UINT8, PF_0ISDIS | PF_PLAYERBASED, STR_CONFIG_PATCHES_SNAP_RADIUS, "window_snap_radius", &_patches.window_snap_radius, 1, 32, 1, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
614 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_INVISIBLE_TREES, "invisible_trees", &_patches.invisible_trees, 0, 1, 1, &InvisibleTreesActive}, |
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
615 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_POPULATION_IN_LABEL, "population_in_label", &_patches.population_in_label, 0, 1, 1, &PopulationInLabelActive}, |
0 | 616 |
}; |
617 |
||
618 |
static const PatchEntry _patches_construction[] = { |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
619 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_BUILDONSLOPES, "build_on_slopes", &_patches.build_on_slopes, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
620 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_EXTRADYNAMITE, "extra_dynamite", &_patches.extra_dynamite, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
621 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_LONGBRIDGES, "long_bridges", &_patches.longbridges, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
622 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SIGNALSIDE, "signal_side", &_patches.signal_side, 0, 0, 0, NULL}, |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
623 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
624 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SMALL_AIRPORTS, "always_small_airport", &_patches.always_small_airport, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
625 |
{PE_UINT8, PF_PLAYERBASED, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY, "drag_signals_density", &_patches.drag_signals_density, 1, 20, 1, NULL}, |
0 | 626 |
|
627 |
}; |
|
628 |
||
629 |
static const PatchEntry _patches_vehicles[] = { |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
630 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_REALISTICACCEL, "realistic_acceleration", &_patches.realistic_acceleration, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
631 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_MAMMOTHTRAINS, "mammoth_trains", &_patches.mammoth_trains, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
632 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_GOTODEPOT, "goto_depot", &_patches.gotodepot, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
633 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_ROADVEH_QUEUE, "roadveh_queue", &_patches.roadveh_queue, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
634 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_NEW_DEPOT_FINDING,"depot_finding", &_patches.new_depot_finding, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
635 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_NEW_TRAIN_PATHFIND,"new_pathfinding", &_patches.new_pathfinding, 0, 0, 0, NULL}, |
0 | 636 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
637 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_WARN_INCOME_LESS, "train_income_warn", &_patches.train_income_warn, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
638 |
{PE_UINT8, PF_MULTISTRING | PF_PLAYERBASED, STR_CONFIG_PATCHES_ORDER_REVIEW, "order_review_system", &_patches.order_review_system,0,2, 1, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
639 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES, "never_expire_vehicles", &_patches.never_expire_vehicles,0,0,0, NULL}, |
0 | 640 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
641 |
{PE_UINT16, PF_0ISDIS | PF_PLAYERBASED, STR_CONFIG_PATCHES_LOST_TRAIN_DAYS, "lost_train_days", &_patches.lost_train_days, 180,720, 60, NULL}, |
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
642 |
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,"autorenew", &_patches.autorenew, 0, 0, 0, NULL}, |
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
643 |
{PE_INT16, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_MONTHS, "autorenew_months", &_patches.autorenew_months, -12, 12, 1, NULL}, |
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
644 |
{PE_CURRENCY, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_MONEY,"autorenew_money", &_patches.autorenew_money, 0, 2000000, 100000, NULL}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
645 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
646 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_TRAINS, "max_trains", &_patches.max_trains, 0,240, 10, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
647 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, "max_roadveh", &_patches.max_roadveh, 0,240, 10, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
648 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT, "max_aircraft", &_patches.max_aircraft, 0,240, 10, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
649 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_SHIPS, "max_ships", &_patches.max_ships, 0,240, 10, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
650 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
651 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SERVINT_ISPERCENT,"servint_isperfect",&_patches.servint_ispercent, 0, 0, 0, &CheckInterval}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
652 |
{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_TRAINS, "servint_trains", &_patches.servint_trains, 5,800, 5, &InValidateDetailsWindow}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
653 |
{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_ROADVEH, "servint_roadveh", &_patches.servint_roadveh, 5,800, 5, &InValidateDetailsWindow}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
654 |
{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, "servint_aircraft", &_patches.servint_aircraft, 5,800, 5, &InValidateDetailsWindow}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
655 |
{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_SHIPS, "servint_ships", &_patches.servint_ships, 5,800, 5, &InValidateDetailsWindow}, |
0 | 656 |
}; |
657 |
||
658 |
static const PatchEntry _patches_stations[] = { |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
659 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_JOINSTATIONS, "join_stations", &_patches.join_stations, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
660 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_FULLLOADANY, "full_load_any", &_patches.full_load_any, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
661 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_IMPROVEDLOAD, "improved_load", &_patches.improved_load, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
662 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SELECTGOODS, "select_goods", &_patches.selectgoods, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
663 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_NEW_NONSTOP, "new_nonstop", &_patches.new_nonstop, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
664 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_NONUNIFORM_STATIONS, "nonuniform_stations", &_patches.nonuniform_stations, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
665 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_STATION_SPREAD, "station_spread", &_patches.station_spread, 4, 64, 1, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
666 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SERVICEATHELIPAD, "service_at_helipad", &_patches.serviceathelipad, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
667 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_CATCHMENT, "modified_catchment", &_patches.modified_catchment}, |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
546
diff
changeset
|
668 |
|
0 | 669 |
}; |
670 |
||
671 |
static const PatchEntry _patches_economy[] = { |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
672 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_INFLATION, "inflation", &_patches.inflation, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
673 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_BUILDXTRAIND, "build_rawmaterial", &_patches.build_rawmaterial_ind, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
674 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_MULTIPINDTOWN, "multiple_industry_per_town", &_patches.multiple_industry_per_town,0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
675 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SAMEINDCLOSE, "same_industry_close", &_patches.same_industry_close, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
676 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_BRIBE, "bribe", &_patches.bribe, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
677 |
{PE_UINT8, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, "snow_line_height", &_patches.snow_line_height, 2, 13, 1, NULL}, |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
678 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
679 |
{PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_COLORED_NEWS_DATE, "colored_new_data", &_patches.colored_news_date, 1900, 2200, 5, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
680 |
{PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date, 1920,2100, 1, NULL}, |
0 | 681 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
682 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, "smooth_economy", &_patches.smooth_economy, 0, 0, 0, NULL}, |
0 | 683 |
}; |
684 |
||
21 | 685 |
static const PatchEntry _patches_ai[] = { |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
686 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_AINEW_ACTIVE, "ainew_active", &_patches.ainew_active, 0, 1, 1, &AiNew_PatchActive_Warning}, |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
68
diff
changeset
|
687 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
688 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, "ai_disable_veh_train", &_patches.ai_disable_veh_train, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
689 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH,"ai_disable_veh_roadveh",&_patches.ai_disable_veh_roadveh, 0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
690 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,"ai_disable_veh_aircraft",&_patches.ai_disable_veh_aircraft,0, 0, 0, NULL}, |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
691 |
{PE_BOOL, 0, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,"ai_disable_veh_ship",&_patches.ai_disable_veh_ship, 0, 0, 0, NULL}, |
21 | 692 |
}; |
693 |
||
0 | 694 |
typedef struct PatchPage { |
695 |
const PatchEntry *entries; |
|
696 |
uint num; |
|
697 |
} PatchPage; |
|
698 |
||
699 |
static const PatchPage _patches_page[] = { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
700 |
{_patches_ui, lengthof(_patches_ui) }, |
0 | 701 |
{_patches_construction, lengthof(_patches_construction) }, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
702 |
{_patches_vehicles, lengthof(_patches_vehicles) }, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
703 |
{_patches_stations, lengthof(_patches_stations) }, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
704 |
{_patches_economy, lengthof(_patches_economy) }, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
705 |
{_patches_ai, lengthof(_patches_ai) }, |
0 | 706 |
}; |
707 |
||
26 | 708 |
extern uint GetCurrentCurrencyRate(); |
709 |
||
0 | 710 |
static int32 ReadPE(const PatchEntry*pe) |
711 |
{ |
|
712 |
switch(pe->type) { |
|
713 |
case PE_BOOL: return *(bool*)pe->variable; |
|
714 |
case PE_UINT8: return *(uint8*)pe->variable; |
|
715 |
case PE_INT16: return *(int16*)pe->variable; |
|
716 |
case PE_UINT16: return *(uint16*)pe->variable; |
|
717 |
case PE_INT32: return *(int32*)pe->variable; |
|
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
718 |
case PE_CURRENCY: return (*(int32*)pe->variable) * GetCurrentCurrencyRate(); |
0 | 719 |
default: |
720 |
NOT_REACHED(); |
|
721 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
722 |
|
0 | 723 |
/* useless, but avoids compiler warning this way */ |
724 |
return 0; |
|
725 |
} |
|
726 |
||
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
727 |
static void WritePE(const PatchEntry *pe, int32 val) |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
728 |
{ |
48
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
729 |
|
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
730 |
if ((pe->flags & PF_0ISDIS) && val <= 0) { |
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
731 |
*(bool*)pe->variable = 0; // "clamp" 'disabled' value to smallest type, PE_BOOL |
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
732 |
return; |
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
733 |
} |
20d80c99ef02
(svn r49) -'Disabled' in patch settings universal for all pe->variable types (dominik81).
darkvater
parents:
47
diff
changeset
|
734 |
|
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
735 |
switch(pe->type) { |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
736 |
case PE_BOOL: *(bool*)pe->variable = (bool)val; break; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
737 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
738 |
case PE_UINT8: if ((uint8)val > (uint8)pe->max) |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
739 |
*(uint8*)pe->variable = (uint8)pe->max; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
740 |
else if ((uint8)val < (uint8)pe->min) |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
741 |
*(uint8*)pe->variable = (uint8)pe->min; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
742 |
else |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
743 |
*(uint8*)pe->variable = (uint8)val; |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
744 |
break; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
745 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
746 |
case PE_INT16: if ((int16)val > (int16)pe->max) |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
747 |
*(int16*)pe->variable = (int16)pe->max; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
748 |
else if ((int16)val < (int16)pe->min) |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
749 |
*(int16*)pe->variable = (int16)pe->min; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
750 |
else |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
751 |
*(int16*)pe->variable = (int16)val; |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
752 |
break; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
753 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
754 |
case PE_UINT16: if ((uint16)val > (uint16)pe->max) |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
755 |
*(uint16*)pe->variable = (uint16)pe->max; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
756 |
else if ((uint16)val < (uint16)pe->min) |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
757 |
*(uint16*)pe->variable = (uint16)pe->min; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
758 |
else |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
759 |
*(uint16*)pe->variable = (uint16)val; |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
760 |
break; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
761 |
|
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
762 |
case PE_CURRENCY: |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
763 |
case PE_INT32: if ((int32)val > (int32)pe->max) |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
764 |
*(int32*)pe->variable = (int32)pe->max; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
765 |
else if ((int32)val < (int32)pe->min) |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
766 |
*(int32*)pe->variable = (int32)pe->min; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
767 |
else |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
768 |
*(int32*)pe->variable = val; |
20
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
769 |
break; |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
770 |
default: |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
771 |
NOT_REACHED(); |
13a47054d81e
(svn r21) Remove: PE_BYTE (bit-bools) in favour of PE_BOOL
truelight
parents:
17
diff
changeset
|
772 |
} |
0 | 773 |
} |
774 |
||
775 |
static void PatchesSelectionWndProc(Window *w, WindowEvent *e) |
|
776 |
{ |
|
777 |
uint i; |
|
778 |
switch(e->event) { |
|
779 |
case WE_PAINT: { |
|
780 |
int x,y; |
|
781 |
const PatchEntry *pe; |
|
782 |
const PatchPage *page; |
|
783 |
uint clk; |
|
784 |
int32 val; |
|
785 |
||
786 |
w->click_state = 1 << (WP(w,def_d).data_1 + 4); |
|
787 |
||
788 |
DrawWindowWidgets(w); |
|
789 |
||
790 |
x = 0; |
|
791 |
y = 46; |
|
792 |
clk = WP(w,def_d).data_2; |
|
793 |
page = &_patches_page[WP(w,def_d).data_1]; |
|
794 |
for(i=0,pe=page->entries; i!=page->num; i++,pe++) { |
|
11
836bc4b37b5b
(svn r12) Change: removed patch no_train_service. Instead you can set the default service interval for any vehicle type to 'disabled'.
dominik
parents:
0
diff
changeset
|
795 |
bool disabled = false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
796 |
bool editable = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
797 |
// We do not allow changes of some items when we are a client in a networkgame |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
798 |
if (!(pe->flags & PF_PLAYERBASED) && _networking && !_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
799 |
editable = false; |
0 | 800 |
if (pe->type == PE_BOOL) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
801 |
if (editable) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
802 |
DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable)?6:4, (*(bool*)pe->variable)?0x20:0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
803 |
else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
804 |
DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable)?7:9, (*(bool*)pe->variable)?0x20:0); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
805 |
SetDParam(0, *(bool*)pe->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
0 | 806 |
} else { |
807 |
DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); |
|
808 |
DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? 0x20 : 0); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
809 |
if (!editable) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
810 |
int color = 0x8000 | _color_list[3].unk2; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
811 |
GfxFillRect(x+6, y+2, x+6+8, y+9, color); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
812 |
GfxFillRect(x+16, y+2, x+16+8, y+9, color); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
813 |
} |
0 | 814 |
DrawStringCentered(x+10, y+1, STR_6819, 0); |
815 |
DrawStringCentered(x+20, y+1, STR_681A, 0); |
|
816 |
||
817 |
val = ReadPE(pe); |
|
26 | 818 |
if (pe->type == PE_CURRENCY) |
819 |
val /= GetCurrentCurrencyRate(); |
|
11
836bc4b37b5b
(svn r12) Change: removed patch no_train_service. Instead you can set the default service interval for any vehicle type to 'disabled'.
dominik
parents:
0
diff
changeset
|
820 |
disabled = ((val == 0) && (pe->flags & PF_0ISDIS)); |
836bc4b37b5b
(svn r12) Change: removed patch no_train_service. Instead you can set the default service interval for any vehicle type to 'disabled'.
dominik
parents:
0
diff
changeset
|
821 |
if (disabled) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
822 |
SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
0 | 823 |
} else { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
824 |
SetDParam(1, val); |
26 | 825 |
if (pe->type == PE_CURRENCY) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
826 |
SetDParam(0, STR_CONFIG_PATCHES_CURRENCY); |
53
1e32a44e2e52
(svn r54) -Add: PF_MULTISTRING in Patch menu to select between things instead of numbers (Celestar)
truelight
parents:
48
diff
changeset
|
827 |
else { |
1e32a44e2e52
(svn r54) -Add: PF_MULTISTRING in Patch menu to select between things instead of numbers (Celestar)
truelight
parents:
48
diff
changeset
|
828 |
if (pe->flags & PF_MULTISTRING) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
829 |
SetDParam(0, pe->str + val + 1); |
53
1e32a44e2e52
(svn r54) -Add: PF_MULTISTRING in Patch menu to select between things instead of numbers (Celestar)
truelight
parents:
48
diff
changeset
|
830 |
else |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
831 |
SetDParam(0, pe->flags & PF_NOCOMMA ? STR_CONFIG_PATCHES_INT32 : STR_7024); |
53
1e32a44e2e52
(svn r54) -Add: PF_MULTISTRING in Patch menu to select between things instead of numbers (Celestar)
truelight
parents:
48
diff
changeset
|
832 |
} |
0 | 833 |
} |
834 |
} |
|
11
836bc4b37b5b
(svn r12) Change: removed patch no_train_service. Instead you can set the default service interval for any vehicle type to 'disabled'.
dominik
parents:
0
diff
changeset
|
835 |
DrawString(30, y+1, (pe->str)+disabled, 0); |
0 | 836 |
y += 11; |
837 |
} |
|
838 |
break; |
|
839 |
} |
|
840 |
||
841 |
case WE_CLICK: |
|
842 |
switch(e->click.widget) { |
|
843 |
case 3: { |
|
844 |
int x,y; |
|
845 |
uint btn; |
|
846 |
const PatchPage *page; |
|
847 |
const PatchEntry *pe; |
|
848 |
||
849 |
y = e->click.pt.y - 46 - 1; |
|
850 |
if (y < 0) return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
851 |
|
0 | 852 |
btn = y / 11; |
853 |
if (y % 11 > 9) return; |
|
854 |
||
855 |
page = &_patches_page[WP(w,def_d).data_1]; |
|
856 |
if (btn >= page->num) return; |
|
857 |
pe = &page->entries[btn]; |
|
858 |
||
859 |
x = e->click.pt.x - 5; |
|
860 |
if (x < 0) return; |
|
861 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
862 |
if (!(pe->flags & PF_PLAYERBASED) && _networking && !_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
863 |
return; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
864 |
|
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
865 |
if (x < 21) { // clicked on the icon on the left side. Either scroller or bool on/off |
0 | 866 |
int32 val = ReadPE(pe), oval = val; |
867 |
||
868 |
switch(pe->type) { |
|
869 |
case PE_BOOL: |
|
870 |
val ^= 1; |
|
871 |
break; |
|
872 |
case PE_UINT8: |
|
873 |
case PE_INT16: |
|
874 |
case PE_UINT16: |
|
875 |
case PE_INT32: |
|
26 | 876 |
case PE_CURRENCY: |
0 | 877 |
// don't allow too fast scrolling |
878 |
if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) { |
|
879 |
_left_button_clicked = false; |
|
880 |
return; |
|
881 |
} |
|
882 |
||
883 |
if (x >= 10) { |
|
884 |
//increase |
|
885 |
if (pe->flags & PF_0ISDIS && val == 0) |
|
886 |
val = pe->min; |
|
887 |
else |
|
888 |
val += pe->step; |
|
889 |
if (val > pe->max) val = pe->max; |
|
890 |
} else { |
|
47
8368e4d4ef07
(svn r48) Fix: Possible to disable some patches (e.g. default service interval) again by setting them to 0
dominik
parents:
46
diff
changeset
|
891 |
// decrease |
0 | 892 |
if (val <= pe->min && pe->flags & PF_0ISDIS) { |
893 |
val = 0; |
|
894 |
} else { |
|
895 |
val -= pe->step; |
|
896 |
if (val < pe->min) val = pe->min; |
|
897 |
} |
|
898 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
899 |
|
0 | 900 |
if (val != oval) { |
901 |
WP(w,def_d).data_2 = btn * 2 + 1 + ((x>=10) ? 1 : 0); |
|
902 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
903 |
_left_button_clicked = false; |
|
904 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
905 |
break; |
0 | 906 |
} |
907 |
if (val != oval) { |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
908 |
// To make patch-changes network-safe |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
909 |
if (pe->type == PE_CURRENCY) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
910 |
val /= GetCurrentCurrencyRate(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
911 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
912 |
// If an item is playerbased, we do not send it over the network (if any) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
913 |
if (pe->flags & PF_PLAYERBASED) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
914 |
WritePE(pe, val); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
915 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
916 |
// Else we do |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
917 |
DoCommandP(0, (byte)WP(w,def_d).data_1 + ((byte)btn << 8), val, NULL, CMD_CHANGE_PATCH_SETTING); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
918 |
} |
0 | 919 |
SetWindowDirty(w); |
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
920 |
|
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
921 |
if (pe->click_proc != NULL) // call callback function |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
922 |
pe->click_proc(val); |
0 | 923 |
} |
924 |
} else { |
|
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
925 |
if (pe->type != PE_BOOL && !(pe->flags & PF_MULTISTRING)) { // do not open editbox |
0 | 926 |
WP(w,def_d).data_3 = btn; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
927 |
SetDParam(0, ReadPE(pe)); |
0 | 928 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0); |
929 |
} |
|
930 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
931 |
|
0 | 932 |
break; |
933 |
} |
|
21 | 934 |
case 4: case 5: case 6: case 7: case 8: case 9: |
0 | 935 |
WP(w,def_d).data_1 = e->click.widget - 4; |
936 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
937 |
SetWindowDirty(w); |
|
938 |
break; |
|
939 |
} |
|
940 |
break; |
|
941 |
||
942 |
case WE_TIMEOUT: |
|
943 |
WP(w,def_d).data_2 = 0; |
|
944 |
SetWindowDirty(w); |
|
945 |
break; |
|
946 |
||
947 |
case WE_ON_EDIT_TEXT: { |
|
948 |
if (*e->edittext.str) { |
|
949 |
const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; |
|
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
950 |
const PatchEntry *pe = &page->entries[WP(w,def_d).data_3]; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
951 |
int32 val; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
952 |
val = atoi(e->edittext.str); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
953 |
if (pe->type == PE_CURRENCY) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
954 |
val /= GetCurrentCurrencyRate(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
955 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
956 |
// If an item is playerbased, we do not send it over the network (if any) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
957 |
if (pe->flags & PF_PLAYERBASED) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
958 |
WritePE(pe, val); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
959 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
960 |
// Else we do |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
961 |
DoCommandP(0, (byte)WP(w,def_d).data_1 + ((byte)WP(w,def_d).data_3 << 8), val, NULL, CMD_CHANGE_PATCH_SETTING); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
962 |
} |
0 | 963 |
SetWindowDirty(w); |
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
964 |
|
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
965 |
if (pe->click_proc != NULL) // call callback function |
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
966 |
pe->click_proc(*(int32*)pe->variable); |
0 | 967 |
} |
968 |
break; |
|
969 |
} |
|
970 |
||
971 |
case WE_DESTROY: |
|
972 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
973 |
break; |
|
974 |
} |
|
975 |
} |
|
976 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
977 |
int32 CmdChangePatchSetting(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
978 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
979 |
const PatchPage *page; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
980 |
const PatchEntry *pe; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
981 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
982 |
if (flags & DC_EXEC) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
983 |
page = &_patches_page[(byte)p1]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
984 |
if (page == NULL) return 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
985 |
pe = &page->entries[(byte)(p1 >> 8)]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
986 |
if (pe == NULL) return 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
987 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
988 |
WritePE(pe, (int32)p2); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
989 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
990 |
InvalidateWindow(WC_GAME_OPTIONS, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
991 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
992 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
993 |
return 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
994 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
995 |
|
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
996 |
/* Those 2 functions need to be here, else we have to make some stuff non-static |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
997 |
and besides, it is also better to keep stuff like this at the same place */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
998 |
void ConsoleSetPatchSetting(char *name, char *value) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
999 |
{ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1000 |
const PatchPage *page; |
631
4da54d38331f
(svn r1062) -Fix: [Console] Compile warnigs in Get/SetPatchSettings
truelight
parents:
629
diff
changeset
|
1001 |
const PatchEntry *pe = NULL; |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1002 |
bool found = false; |
639
998f233b6db3
(svn r1072) Fixed a few warnings that made trouble in VS .NET 2003
dominik
parents:
631
diff
changeset
|
1003 |
int i; |
998f233b6db3
(svn r1072) Fixed a few warnings that made trouble in VS .NET 2003
dominik
parents:
631
diff
changeset
|
1004 |
unsigned int j; |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1005 |
int val; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1006 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1007 |
/* Search for the name in the patch-settings */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1008 |
for (i = 0; i < lengthof(_patches_page); i++) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1009 |
page = &_patches_page[i]; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1010 |
for (j = 0; j < page->num; j++) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1011 |
pe = &page->entries[j]; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1012 |
if (strncmp(pe->console_name, name, sizeof(pe->console_name)) == 0) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1013 |
/* We found the name */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1014 |
found = true; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1015 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1016 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1017 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1018 |
if (found) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1019 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1020 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1021 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1022 |
/* We did not found the patch setting */ |
631
4da54d38331f
(svn r1062) -Fix: [Console] Compile warnigs in Get/SetPatchSettings
truelight
parents:
629
diff
changeset
|
1023 |
if (!found || pe == NULL) { |
629
ce914eb4023d
(svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents:
625
diff
changeset
|
1024 |
IConsolePrintF(_iconsole_color_warning, "'%s' is an unkown patch setting", name); |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1025 |
return; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1026 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1027 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1028 |
val = atoi(value); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1029 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1030 |
if (pe->type == PE_CURRENCY) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1031 |
val /= GetCurrentCurrencyRate(); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1032 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1033 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1034 |
// If an item is playerbased, we do not send it over the network (if any) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1035 |
if (pe->flags & PF_PLAYERBASED) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1036 |
WritePE(pe, val); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1037 |
} else { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1038 |
// Else we do |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1039 |
DoCommandP(0, i + (j << 8), val, NULL, CMD_CHANGE_PATCH_SETTING); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1040 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1041 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1042 |
switch(pe->type) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1043 |
case PE_BOOL: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1044 |
if (val == 1) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1045 |
snprintf(value, sizeof(value), "enabled"); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1046 |
else |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1047 |
snprintf(value, sizeof(value), "disabled"); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1048 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1049 |
default: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1050 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1051 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1052 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1053 |
IConsolePrintF(_iconsole_color_warning, "'%s' changed in:", name); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1054 |
IConsolePrintF(_iconsole_color_warning, " '%s'", value); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1055 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1056 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1057 |
void ConsoleGetPatchSetting(char *name) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1058 |
{ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1059 |
const PatchPage *page; |
631
4da54d38331f
(svn r1062) -Fix: [Console] Compile warnigs in Get/SetPatchSettings
truelight
parents:
629
diff
changeset
|
1060 |
const PatchEntry *pe = NULL; |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1061 |
char value[50]; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1062 |
bool found = false; |
639
998f233b6db3
(svn r1072) Fixed a few warnings that made trouble in VS .NET 2003
dominik
parents:
631
diff
changeset
|
1063 |
int i; |
998f233b6db3
(svn r1072) Fixed a few warnings that made trouble in VS .NET 2003
dominik
parents:
631
diff
changeset
|
1064 |
unsigned int j; |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1065 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1066 |
/* Search for the name in the patch-settings */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1067 |
for (i = 0; i < lengthof(_patches_page); i++) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1068 |
page = &_patches_page[i]; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1069 |
for (j = 0; j < page->num; j++) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1070 |
pe = &page->entries[j]; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1071 |
if (strncmp(pe->console_name, name, sizeof(pe->console_name)) == 0) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1072 |
/* We found the name */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1073 |
found = true; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1074 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1075 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1076 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1077 |
if (found) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1078 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1079 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1080 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1081 |
/* We did not found the patch setting */ |
631
4da54d38331f
(svn r1062) -Fix: [Console] Compile warnigs in Get/SetPatchSettings
truelight
parents:
629
diff
changeset
|
1082 |
if (!found || pe == NULL) { |
629
ce914eb4023d
(svn r1059) -Fix: [Console] Renamed 'set port' to 'set server_port'
truelight
parents:
625
diff
changeset
|
1083 |
IConsolePrintF(_iconsole_color_warning, "'%s' is an unkown patch setting", name); |
625
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1084 |
return; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1085 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1086 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1087 |
/* 'pe' is now the correct patch setting */ |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1088 |
switch(pe->type) { |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1089 |
case PE_BOOL: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1090 |
if (ReadPE(pe) == 1) |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1091 |
snprintf(value, sizeof(value), "enabled"); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1092 |
else |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1093 |
snprintf(value, sizeof(value), "disabled"); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1094 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1095 |
case PE_UINT8: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1096 |
case PE_INT16: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1097 |
case PE_UINT16: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1098 |
case PE_INT32: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1099 |
case PE_CURRENCY: |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1100 |
snprintf(value, sizeof(value), "%d", ReadPE(pe)); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1101 |
break; |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1102 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1103 |
|
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1104 |
IConsolePrintF(_iconsole_color_warning, "Current value for '%s' is:", name); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1105 |
IConsolePrintF(_iconsole_color_warning, " '%s'", value); |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1106 |
} |
682ead270492
(svn r1055) -Add: [Console] Special for dedicated servers:
truelight
parents:
579
diff
changeset
|
1107 |
|
0 | 1108 |
static const Widget _patches_selection_widgets[] = { |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1109 |
{ WWT_CLOSEBOX, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1110 |
{ WWT_CAPTION, 10, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1111 |
{ WWT_PANEL, 10, 0, 369, 14, 41, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1112 |
{ WWT_PANEL, 10, 0, 369, 42, 320, 0x0, STR_NULL}, |
0 | 1113 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1114 |
{ WWT_CLOSEBOX, 3, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1115 |
{ WWT_CLOSEBOX, 3, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1116 |
{ WWT_CLOSEBOX, 3, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1117 |
{ WWT_CLOSEBOX, 3, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1118 |
{ WWT_CLOSEBOX, 3, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1119 |
{ WWT_CLOSEBOX, 3, 97, 183, 28, 39, STR_CONFIG_PATCHES_AI, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
1120 |
{ WIDGETS_END}, |
0 | 1121 |
}; |
1122 |
||
1123 |
static const WindowDesc _patches_selection_desc = { |
|
1124 |
WDP_CENTER, WDP_CENTER, 370, 321, |
|
1125 |
WC_GAME_OPTIONS,0, |
|
1126 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1127 |
_patches_selection_widgets, |
|
1128 |
PatchesSelectionWndProc, |
|
1129 |
}; |
|
1130 |
||
1131 |
void ShowPatchesSelection() |
|
1132 |
{ |
|
1133 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
1134 |
AllocateWindowDesc(&_patches_selection_desc); |
|
1135 |
} |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1136 |
|
484 | 1137 |
struct GRFFile *_sel_grffile; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1138 |
|
484 | 1139 |
enum { |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1140 |
NEWGRF_WND_PROC_OFFSET_TOP_WIDGET = 14, |
484 | 1141 |
NEWGRF_WND_PROC_ROWSIZE = 14 |
1142 |
}; |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1143 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1144 |
static void NewgrfWndProc(Window *w, WindowEvent *e) |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1145 |
{ |
484 | 1146 |
switch (e->event) { |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1147 |
case WE_PAINT: { |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1148 |
int x, y = NEWGRF_WND_PROC_OFFSET_TOP_WIDGET; |
484 | 1149 |
uint16 i = 0; |
1150 |
struct GRFFile *c = _first_grffile; |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1151 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1152 |
DrawWindowWidgets(w); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
1153 |
|
484 | 1154 |
if (_first_grffile == NULL) { // no grf sets installed |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1155 |
DrawStringMultiCenter(140, 210, STR_NEWGRF_NO_FILES_INSTALLED, 250); |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1156 |
break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1157 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1158 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1159 |
// draw list of all grf files |
484 | 1160 |
while (c != NULL) { |
1161 |
if (i >= w->vscroll.pos) { // draw files according to scrollbar position |
|
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1162 |
bool h = (_sel_grffile==c); |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1163 |
// show highlighted item with a different background and highlighted text |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
1164 |
if(h) GfxFillRect(1, y + 1, 267, y + 12, 156); |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1165 |
// XXX - will be grf name later |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
1166 |
DoDrawString(c->filename, 25, y + 2, h ? 0xC : 0x10); |
579
08ce4c50bd32
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
568
diff
changeset
|
1167 |
DrawSprite(SPRITE_PALETTE(SPR_SQUARE | 0x30b8000), 5, y + 2); |
484 | 1168 |
y += NEWGRF_WND_PROC_ROWSIZE; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1169 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
1170 |
|
484 | 1171 |
c = c->next; |
1172 |
if (++i == w->vscroll.cap + w->vscroll.pos) break; // stop after displaying 12 items |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1173 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1174 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1175 |
// DoDrawString(_sel_grffile->setname, 120, 200, 0x01); // draw grf name |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1176 |
|
484 | 1177 |
if (_sel_grffile == NULL) { // no grf file selected yet |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1178 |
DrawStringMultiCenter(140, 210, STR_NEWGRF_TIP, 250); |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1179 |
} else { |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1180 |
// draw filename |
484 | 1181 |
x = DrawString(5, 199, STR_NEWGRF_FILENAME, 0); |
1182 |
DoDrawString(_sel_grffile->filename, x + 2, 199, 0x01); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
1183 |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1184 |
// draw grf id |
484 | 1185 |
x = DrawString(5, 209, STR_NEWGRF_GRF_ID, 0); |
486
dadcb8d5a6bd
(svn r768) In the NewGRF manager, show GRF ids as 8-digit hex numbers (that's how they are supposed to look).
pasky
parents:
484
diff
changeset
|
1186 |
snprintf(_userstring, USERSTRING_LEN, "%08X", _sel_grffile->grfid); |
dadcb8d5a6bd
(svn r768) In the NewGRF manager, show GRF ids as 8-digit hex numbers (that's how they are supposed to look).
pasky
parents:
484
diff
changeset
|
1187 |
DrawString(x + 2, 209, STR_SPEC_USERSTRING, 0x01); |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1188 |
} |
484 | 1189 |
} break; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1190 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1191 |
case WE_CLICK: |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1192 |
switch(e->click.widget) { |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1193 |
case 2: { // select a grf file |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1194 |
int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1195 |
|
484 | 1196 |
if (y >= w->vscroll.cap) { return;} // click out of bounds |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1197 |
|
484 | 1198 |
y += w->vscroll.pos; |
1199 |
||
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1200 |
if (y >= _grffile_count) return; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1201 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1202 |
_sel_grffile = _first_grffile; |
484 | 1203 |
// get selected grf-file |
1204 |
while (y-- != 0) _sel_grffile = _sel_grffile->next; |
|
1205 |
||
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1206 |
SetWindowDirty(w); |
484 | 1207 |
} break; |
1208 |
case 9: /* Cancel button */ |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1209 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1210 |
break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1211 |
} break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1212 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1213 |
/* Parameter edit box not used yet |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1214 |
case WE_TIMEOUT: |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1215 |
WP(w,def_d).data_2 = 0; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1216 |
SetWindowDirty(w); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1217 |
break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1218 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1219 |
case WE_ON_EDIT_TEXT: { |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1220 |
if (*e->edittext.str) { |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1221 |
SetWindowDirty(w); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1222 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1223 |
break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1224 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1225 |
*/ |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1226 |
case WE_DESTROY: |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1227 |
_sel_grffile = NULL; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1228 |
DeleteWindowById(WC_QUERY_STRING, 0); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1229 |
break; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1230 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1231 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1232 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1233 |
static const Widget _newgrf_widgets[] = { |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1234 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1235 |
{ WWT_CAPTION, 14, 11, 279, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1236 |
{ WWT_MATRIX, 14, 0, 268, 14, 182, 0xC01,/*small rows*/ STR_NEWGRF_TIP}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1237 |
{ WWT_PANEL, 14, 0, 279, 183, 276, 0x0, STR_NULL}, |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1238 |
|
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1239 |
{ WWT_SCROLLBAR, 14, 269, 279, 14, 182, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1240 |
|
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1241 |
{ WWT_CLOSEBOX, 14, 147, 158, 244, 255, STR_0188, STR_NULL}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1242 |
{ WWT_CLOSEBOX, 14, 159, 170, 244, 255, STR_0189, STR_NULL}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1243 |
{ WWT_CLOSEBOX, 14, 175, 274, 244, 255, STR_NEWGRF_SET_PARAMETERS, STR_NULL}, |
484 | 1244 |
|
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1245 |
{ WWT_CLOSEBOX, 3, 5, 138, 261, 272, STR_NEWGRF_APPLY_CHANGES, STR_NULL}, |
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1246 |
{ WWT_CLOSEBOX, 3, 142, 274, 261, 272, STR_012E_CANCEL, STR_NULL}, |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1247 |
{ WIDGETS_END}, |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1248 |
}; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1249 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1250 |
static const WindowDesc _newgrf_desc = { |
502
c2db77551c24
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1251 |
WDP_CENTER, WDP_CENTER, 280, 277, |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1252 |
WC_GAME_OPTIONS,0, |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1253 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1254 |
_newgrf_widgets, |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1255 |
NewgrfWndProc, |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1256 |
}; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1257 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1258 |
void ShowNewgrf() |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1259 |
{ |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1260 |
Window *w; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1261 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1262 |
w = AllocateWindowDesc(&_newgrf_desc); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1263 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1264 |
{ // little helper function to calculate _grffile_count |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1265 |
// should be REMOVED once _grffile_count is calculated at loading |
484 | 1266 |
struct GRFFile *c = _first_grffile; |
1267 |
_grffile_count = 0; |
|
1268 |
while (c != NULL) { |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1269 |
_grffile_count++; |
484 | 1270 |
c = c->next; |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1271 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1272 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1273 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1274 |
w->vscroll.cap = 12; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1275 |
w->vscroll.count = _grffile_count; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1276 |
w->vscroll.pos = 0; |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1277 |
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7); |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1278 |
} |
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1279 |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1280 |
/* state: 0 = none clicked, 0x01 = first clicked, 0x02 = second clicked */ |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1281 |
void DrawArrowButtons(int x, int y, int state) |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1282 |
{ |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1283 |
DrawFrameRect(x, y+1, x+9, y+9, 3, (state&0x01) ? 0x20 : 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1284 |
DrawFrameRect(x+10, y+1, x+19, y+9, 3, (state&0x02) ? 0x20 : 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1285 |
DrawStringCentered(x+5, y+1, STR_6819, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1286 |
DrawStringCentered(x+15, y+1, STR_681A, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1287 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1288 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1289 |
char str_separator[2]; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1290 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1291 |
static void CustCurrencyWndProc(Window *w, WindowEvent *e) |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1292 |
{ |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1293 |
switch (e->event) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1294 |
case WE_PAINT: { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1295 |
int x=35, y=20, i=0; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1296 |
int clk = WP(w,def_d).data_1; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1297 |
DrawWindowWidgets(w); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1298 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1299 |
// exchange rate |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1300 |
DrawArrowButtons(10, y, (clk >> (i*2)) & 0x03); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1301 |
SetDParam(0, 1); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1302 |
SetDParam(1, 1); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1303 |
DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1304 |
x = 35; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1305 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1306 |
i++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1307 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1308 |
// separator |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1309 |
DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1310 |
x = DrawString(x, y + 1, STR_CURRENCY_SEPARATOR, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1311 |
DoDrawString(str_separator, x + 4, y + 1, 6); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1312 |
x = 35; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1313 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1314 |
i++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1315 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1316 |
// prefix |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1317 |
DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1318 |
x = DrawString(x, y + 1, STR_CURRENCY_PREFIX, 0); |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1319 |
DoDrawString(_currency_specs[23].prefix, x + 4, y + 1, 6); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1320 |
x = 35; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1321 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1322 |
i++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1323 |
|
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1324 |
// suffix |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1325 |
DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03)?0x20:0x00); |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1326 |
x = DrawString(x, y + 1, STR_CURRENCY_SUFFIX, 0); |
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1327 |
DoDrawString(_currency_specs[23].suffix, x + 4, y + 1, 6); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1328 |
x = 35; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1329 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1330 |
i++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1331 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1332 |
// switch to euro |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1333 |
DrawArrowButtons(10, y, (clk >> (i*2)) & 0x03); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1334 |
SetDParam(0, _currency_specs[23].to_euro); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1335 |
DrawString(x, y + 1, (_currency_specs[23].to_euro)?STR_CURRENCY_SWITCH_TO_EURO:STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1336 |
x = 35; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1337 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1338 |
i++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1339 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1340 |
// Preview |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1341 |
y+=12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1342 |
SetDParam(0, 10000); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1343 |
DrawString(x, y + 1, STR_CURRENCY_PREVIEW, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1344 |
} break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1345 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1346 |
case WE_CLICK: { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1347 |
bool edittext = false; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1348 |
int line = (e->click.pt.y - 20)/12; |
776
d2e1f9c15bd3
(svn r1242) -Fix: fix some morhpos warnings (tokai)
darkvater
parents:
759
diff
changeset
|
1349 |
int len = 0; |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1350 |
int x = e->click.pt.x; |
776
d2e1f9c15bd3
(svn r1242) -Fix: fix some morhpos warnings (tokai)
darkvater
parents:
759
diff
changeset
|
1351 |
StringID str = 0; |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1352 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1353 |
switch ( line ) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1354 |
case 0: // rate |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1355 |
if ( IS_INT_INSIDE(x, 10, 30) ) { // clicked buttons |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1356 |
if (x < 20) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1357 |
_currency_specs[23].rate = max(1, _currency_specs[23].rate-1); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1358 |
WP(w,def_d).data_1 = (1 << (line * 2 + 0)); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1359 |
} else { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1360 |
_currency_specs[23].rate = min(5000, _currency_specs[23].rate+1); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1361 |
WP(w,def_d).data_1 = (1 << (line * 2 + 1)); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1362 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1363 |
} else { // enter text |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1364 |
SetDParam(0, _currency_specs[23].rate); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1365 |
str = STR_CONFIG_PATCHES_INT32; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1366 |
len = 4; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1367 |
edittext = true; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1368 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1369 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1370 |
case 1: // separator |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1371 |
if ( IS_INT_INSIDE(x, 10, 30) ) // clicked button |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1372 |
WP(w,def_d).data_1 = (1 << (line * 2 + 1)); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1373 |
str = AllocateName(str_separator, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1374 |
len = 1; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1375 |
edittext = true; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1376 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1377 |
case 2: // prefix |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1378 |
if ( IS_INT_INSIDE(x, 10, 30) ) // clicked button |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1379 |
WP(w,def_d).data_1 = (1 << (line * 2 + 1)); |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1380 |
str = AllocateName(_currency_specs[23].prefix, 0); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1381 |
len = 12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1382 |
edittext = true; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1383 |
break; |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1384 |
case 3: // suffix |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1385 |
if ( IS_INT_INSIDE(x, 10, 30) ) // clicked button |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1386 |
WP(w,def_d).data_1 = (1 << (line * 2 + 1)); |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1387 |
str = AllocateName(_currency_specs[23].suffix, 0); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1388 |
len = 12; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1389 |
edittext = true; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1390 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1391 |
case 4: // to euro |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1392 |
if ( IS_INT_INSIDE(x, 10, 30) ) { // clicked buttons |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1393 |
if (x < 20) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1394 |
if(_currency_specs[23].to_euro <= 2000) _currency_specs[23].to_euro = 0; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1395 |
else _currency_specs[23].to_euro--; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1396 |
WP(w,def_d).data_1 = (1 << (line * 2 + 0)); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1397 |
} else { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1398 |
if(_currency_specs[23].to_euro == 0) _currency_specs[23].to_euro = 2000; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1399 |
else _currency_specs[23].to_euro++; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1400 |
_currency_specs[23].to_euro = min(2090, _currency_specs[23].to_euro); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1401 |
WP(w,def_d).data_1 = (1 << (line * 2 + 1)); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1402 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1403 |
} else { // enter text |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1404 |
SetDParam(0, _currency_specs[23].to_euro); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1405 |
str = STR_CONFIG_PATCHES_INT32; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1406 |
len = 4; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1407 |
edittext = true; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1408 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1409 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1410 |
} |
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1411 |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1412 |
if(edittext) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1413 |
WP(w,def_d).data_2 = line; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1414 |
ShowQueryString( |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1415 |
str, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1416 |
STR_CURRENCY_CHANGE_PARAMETER, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1417 |
len, // maximum number of characters OR |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1418 |
250, // characters up to this width pixels, whichever is satisfied first |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1419 |
w->window_class, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1420 |
w->window_number); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1421 |
if (str != STR_CONFIG_PATCHES_INT32) DeleteName(str); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1422 |
} |
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1423 |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1424 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1425 |
SetWindowDirty(w); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1426 |
} break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1427 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1428 |
case WE_ON_EDIT_TEXT: { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1429 |
int val; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1430 |
byte *b = e->edittext.str; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1431 |
switch (WP(w,def_d).data_2) { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1432 |
case 0: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1433 |
val = atoi(b); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1434 |
val = clamp(val, 1, 5000); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1435 |
_currency_specs[23].rate = val; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1436 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1437 |
case 1: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1438 |
_currency_specs[23].separator = b[0]; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1439 |
ttd_strlcpy(str_separator, b, 16); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1440 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1441 |
case 2: |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1442 |
ttd_strlcpy(_currency_specs[23].prefix, b, 16); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1443 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1444 |
case 3: |
788
f7c5d8966d59
(svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents:
776
diff
changeset
|
1445 |
ttd_strlcpy(_currency_specs[23].suffix, b, 16); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1446 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1447 |
case 4: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1448 |
val = atoi(b); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1449 |
val = clamp(val, 1999, 2090); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1450 |
if (val == 1999) val = 0; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1451 |
_currency_specs[23].to_euro = val; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1452 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1453 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1454 |
MarkWholeScreenDirty(); |
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1455 |
|
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1456 |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1457 |
} break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1458 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1459 |
case WE_TIMEOUT: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1460 |
WP(w,def_d).data_1 = 0; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1461 |
SetWindowDirty(w); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1462 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1463 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1464 |
case WE_DESTROY: |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1465 |
DeleteWindowById(WC_QUERY_STRING, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1466 |
MarkWholeScreenDirty(); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1467 |
break; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1468 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1469 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1470 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1471 |
static const Widget _cust_currency_widgets[] = { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1472 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1473 |
{ WWT_CAPTION, 14, 11, 229, 0, 13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1474 |
{ WWT_PANEL, 14, 0, 229, 14, 119, 0x0, STR_NULL}, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1475 |
{ WIDGETS_END}, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1476 |
}; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1477 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1478 |
static const WindowDesc _cust_currency_desc = { |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1479 |
WDP_CENTER, WDP_CENTER, 230, 120, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1480 |
WC_CUSTOM_CURRENCY, 0, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1481 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1482 |
_cust_currency_widgets, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1483 |
CustCurrencyWndProc, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1484 |
}; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1485 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1486 |
void ShowCustCurrency() |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1487 |
{ |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1488 |
Window *w; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1489 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1490 |
str_separator[0] = _currency_specs[23].separator; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1491 |
str_separator[1] = '\0'; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1492 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1493 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1494 |
w = AllocateWindowDesc(&_cust_currency_desc); |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1495 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1496 |