author | tron |
Thu, 31 Aug 2006 14:12:08 +0000 | |
changeset 4488 | 1be86990ea3e |
parent 4444 | 8d40844e6755 |
child 4549 | 106ed18a7675 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1806
diff
changeset
|
4 |
#include "openttd.h" |
2291
c142846954ee
(svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
2231
diff
changeset
|
5 |
#include "currency.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1309
diff
changeset
|
7 |
#include "string.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1282
diff
changeset
|
8 |
#include "strings.h" // XXX GetCurrentCurrencyRate() |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1323
diff
changeset
|
9 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
502
diff
changeset
|
10 |
#include "table/strings.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "gfx.h" |
|
14 |
#include "command.h" |
|
15 |
#include "engine.h" |
|
430 | 16 |
#include "screenshot.h" |
478
3a161108a15d
(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
|
17 |
#include "newgrf.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
18 |
#include "network.h" |
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
19 |
#include "town.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2140
diff
changeset
|
20 |
#include "variables.h" |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
21 |
#include "settings.h" |
3577
c6532e0bee4c
(svn r4463) -Codechange. Include vehicle.h directly instead of implicitly via station.h in a number of source files
celestar
parents:
3491
diff
changeset
|
22 |
#include "vehicle.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4211
diff
changeset
|
23 |
#include "date.h" |
0 | 24 |
|
25 |
static uint32 _difficulty_click_a; |
|
26 |
static uint32 _difficulty_click_b; |
|
27 |
static byte _difficulty_timeout; |
|
28 |
||
3342
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
29 |
static const StringID _units_dropdown[] = { |
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
30 |
STR_UNITS_IMPERIAL, |
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
31 |
STR_UNITS_METRIC, |
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
32 |
STR_UNITS_SI, |
0 | 33 |
INVALID_STRING_ID |
34 |
}; |
|
35 |
||
36 |
static const StringID _driveside_dropdown[] = { |
|
37 |
STR_02E9_DRIVE_ON_LEFT, |
|
38 |
STR_02EA_DRIVE_ON_RIGHT, |
|
39 |
INVALID_STRING_ID |
|
40 |
}; |
|
41 |
||
42 |
static const StringID _autosave_dropdown[] = { |
|
43 |
STR_02F7_OFF, |
|
44 |
STR_AUTOSAVE_1_MONTH, |
|
45 |
STR_02F8_EVERY_3_MONTHS, |
|
46 |
STR_02F9_EVERY_6_MONTHS, |
|
47 |
STR_02FA_EVERY_12_MONTHS, |
|
48 |
INVALID_STRING_ID, |
|
49 |
}; |
|
50 |
||
51 |
static const StringID _designnames_dropdown[] = { |
|
52 |
STR_02BE_DEFAULT, |
|
53 |
STR_02BF_CUSTOM, |
|
54 |
INVALID_STRING_ID |
|
55 |
}; |
|
56 |
||
57 |
static StringID *BuildDynamicDropdown(StringID base, int num) |
|
58 |
{ |
|
59 |
static StringID buf[32 + 1]; |
|
60 |
StringID *p = buf; |
|
61 |
while (--num>=0) *p++ = base++; |
|
62 |
*p = INVALID_STRING_ID; |
|
63 |
return buf; |
|
64 |
} |
|
65 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
66 |
static int GetCurRes(void) |
0 | 67 |
{ |
68 |
int i; |
|
2639 | 69 |
|
70 |
for (i = 0; i != _num_resolutions; i++) { |
|
306
9ba288cacf0a
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
71 |
if (_resolutions[i][0] == _screen.width && |
2639 | 72 |
_resolutions[i][1] == _screen.height) { |
0 | 73 |
break; |
2639 | 74 |
} |
75 |
} |
|
0 | 76 |
return i; |
77 |
} |
|
78 |
||
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
79 |
static inline bool RoadVehiclesAreBuilt(void) |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
80 |
{ |
2639 | 81 |
const Vehicle* v; |
82 |
||
915 | 83 |
FOR_ALL_VEHICLES(v) { |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
84 |
if (v->type == VEH_Road) return true; |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
85 |
} |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
86 |
return false; |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
87 |
} |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
88 |
|
2817 | 89 |
|
90 |
static void ShowCustCurrency(void); |
|
91 |
||
0 | 92 |
static void GameOptionsWndProc(Window *w, WindowEvent *e) |
93 |
{ |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
94 |
switch (e->event) { |
0 | 95 |
case WE_PAINT: { |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
96 |
int i; |
0 | 97 |
StringID str = STR_02BE_DEFAULT; |
98 |
w->disabled_state = (_vehicle_design_names & 1) ? (++str, 0) : (1 << 21); |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
99 |
SetDParam(0, str); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4344
diff
changeset
|
100 |
SetDParam(1, _currency_specs[_opt_ptr->currency].name); |
3342
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
101 |
SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
102 |
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side); |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
103 |
SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_ptr->town_name); |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
104 |
SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
105 |
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr); |
0 | 106 |
i = GetCurRes(); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
107 |
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
108 |
SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); |
298
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
109 |
(_fullscreen) ? SETBIT(w->click_state, 28) : CLRBIT(w->click_state, 28); // fullscreen button |
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
110 |
|
0 | 111 |
DrawWindowWidgets(w); |
298
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
112 |
DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen |
0 | 113 |
} break; |
114 |
||
115 |
case WE_CLICK: |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
116 |
switch (e->click.widget) { |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
117 |
case 4: case 5: /* Setup currencies dropdown */ |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4344
diff
changeset
|
118 |
ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, 5, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);; |
0 | 119 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
120 |
case 7: case 8: /* Setup distance unit dropdown */ |
3342
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
121 |
ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, 8, 0, 0); |
0 | 122 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
123 |
case 10: case 11: { /* Setup road-side dropdown */ |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
124 |
int i = 0; |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
125 |
|
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
126 |
/* You can only change the drive side if you are in the menu or ingame with |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
127 |
* no vehicles present. In a networking game only the server can change it */ |
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
128 |
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
129 |
i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
130 |
|
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
131 |
ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, 11, i, 0); |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
132 |
} return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
133 |
case 13: case 14: { /* Setup townname dropdown */ |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
134 |
int i = _opt_ptr->town_name; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
135 |
ShowDropDownMenu(w, BuildDynamicDropdown(STR_TOWNNAME_ORIGINAL_ENGLISH, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1), i, 14, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0); |
0 | 136 |
return; |
137 |
} |
|
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
138 |
case 16: case 17: /* Setup autosave dropdown */ |
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
139 |
ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, 17, 0, 0); |
0 | 140 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
141 |
case 19: case 20: /* Setup customized vehicle-names dropdown */ |
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
142 |
ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, 20, (_vehicle_design_names & 2) ? 0 : 2, 0); |
0 | 143 |
return; |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
144 |
case 21: /* Save customized vehicle-names to disk */ |
0 | 145 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
146 |
case 23: case 24: /* Setup interface language dropdown */ |
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
147 |
ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, 24, 0, 0); |
0 | 148 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
149 |
case 26: case 27: /* Setup resolution dropdown */ |
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
150 |
ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), 27, 0, 0); |
0 | 151 |
return; |
298
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
152 |
case 28: /* Click fullscreen on/off */ |
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
153 |
(_fullscreen) ? CLRBIT(w->click_state, 28) : SETBIT(w->click_state, 28); |
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
154 |
ToggleFullScreen(!_fullscreen); // toggle full-screen on/off |
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
155 |
SetWindowDirty(w); |
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
156 |
return; |
1806
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
157 |
case 30: case 31: /* Setup screenshot format dropdown */ |
5a55d508c23e
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1805
diff
changeset
|
158 |
ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, 31, 0, 0); |
0 | 159 |
return; |
160 |
} |
|
161 |
break; |
|
162 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
163 |
case WE_DROPDOWN_SELECT: |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
164 |
switch (e->dropdown.button) { |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
165 |
case 20: /* Vehicle design names */ |
0 | 166 |
if (e->dropdown.index == 0) { |
167 |
DeleteCustomEngineNames(); |
|
168 |
MarkWholeScreenDirty(); |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
169 |
} else if (!(_vehicle_design_names & 1)) { |
0 | 170 |
LoadCustomEngineNames(); |
171 |
MarkWholeScreenDirty(); |
|
172 |
} |
|
173 |
break; |
|
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
174 |
case 5: /* Currency */ |
3596
6654541a3958
(svn r4487) - Codechange: replace the custom currency magic number 23 with a define
peter1138
parents:
3577
diff
changeset
|
175 |
if (e->dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
176 |
_opt_ptr->currency = e->dropdown.index; |
0 | 177 |
MarkWholeScreenDirty(); |
178 |
break; |
|
3342
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
179 |
case 8: /* Measuring units */ |
cb9b5c6dd74c
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
180 |
_opt_ptr->units = e->dropdown.index; |
0 | 181 |
MarkWholeScreenDirty(); |
182 |
break; |
|
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
183 |
case 11: /* Road side */ |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
184 |
if (_opt_ptr->road_side != e->dropdown.index) { // only change if setting changed |
1803
8fd9dca6d2c6
(svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents:
1796
diff
changeset
|
185 |
DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); |
1113
da5c5c571541
(svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents:
1095
diff
changeset
|
186 |
MarkWholeScreenDirty(); |
da5c5c571541
(svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents:
1095
diff
changeset
|
187 |
} |
0 | 188 |
break; |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
189 |
case 14: /* Town names */ |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
190 |
if (_game_mode == GM_MENU) { |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
191 |
_opt_ptr->town_name = e->dropdown.index; |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
192 |
InvalidateWindow(WC_GAME_OPTIONS, 0); |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
193 |
} |
0 | 194 |
break; |
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
195 |
case 17: /* Autosave options */ |
4196
1df4eeea1f81
(svn r5656) -Fix [SF 1296259]: Autosave override. Changing autosave interval ingame should also change the default interval.
Darkvater
parents:
3900
diff
changeset
|
196 |
_opt.autosave = _opt_newgame.autosave = e->dropdown.index; |
0 | 197 |
SetWindowDirty(w); |
198 |
break; |
|
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
199 |
case 24: /* Change interface language */ |
0 | 200 |
ReadLanguagePack(e->dropdown.index); |
201 |
MarkWholeScreenDirty(); |
|
202 |
break; |
|
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
203 |
case 27: /* Change resolution */ |
0 | 204 |
if (e->dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->dropdown.index][0],_resolutions[e->dropdown.index][1])) |
205 |
SetWindowDirty(w); |
|
206 |
break; |
|
871
0143ae5b4112
(svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents:
867
diff
changeset
|
207 |
case 31: /* Change screenshot format */ |
0 | 208 |
SetScreenshotFormat(e->dropdown.index); |
209 |
SetWindowDirty(w); |
|
210 |
break; |
|
211 |
} |
|
212 |
break; |
|
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
213 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
214 |
case WE_DESTROY: |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
215 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
216 |
break; |
0 | 217 |
} |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
218 |
|
0 | 219 |
} |
220 |
||
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
221 |
/** Change the side of the road vehicles drive on (server only). |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3342
diff
changeset
|
222 |
* @param tile unused |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
223 |
* @param p1 the side of the road; 0 = left side and 1 = right side |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
224 |
* @param p2 unused |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
225 |
*/ |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3342
diff
changeset
|
226 |
int32 CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 227 |
{ |
1803
8fd9dca6d2c6
(svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents:
1796
diff
changeset
|
228 |
/* Check boundaries and you can only change this if NO vehicles have been built yet, |
8fd9dca6d2c6
(svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents:
1796
diff
changeset
|
229 |
* except in the intro-menu where of course it's always possible to do so. */ |
8fd9dca6d2c6
(svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents:
1796
diff
changeset
|
230 |
if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR; |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
231 |
|
0 | 232 |
if (flags & DC_EXEC) { |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
233 |
_opt_ptr->road_side = p1; |
0 | 234 |
InvalidateWindow(WC_GAME_OPTIONS,0); |
235 |
} |
|
236 |
return 0; |
|
237 |
} |
|
238 |
||
239 |
static const Widget _game_options_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
240 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
241 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
242 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 238, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
243 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
244 |
{ WWT_6, RESIZE_NONE, 14, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
245 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 158, 168, 35, 44, STR_0225, STR_02E2_CURRENCY_UNITS_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
246 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
247 |
{ WWT_6, RESIZE_NONE, 14, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
248 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 338, 348, 35, 44, STR_0225, STR_MEASURING_UNITS_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
249 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
250 |
{ WWT_6, RESIZE_NONE, 14, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
251 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 158, 168, 77, 86, STR_0225, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
252 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
253 |
{ WWT_6, RESIZE_NONE, 14, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
254 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 338, 348, 77, 86, STR_0225, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
255 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
256 |
{ WWT_6, RESIZE_NONE, 14, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
257 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 158, 168, 119, 128, STR_0225, STR_02F6_SELECT_INTERVAL_BETWEEN}, |
0 | 258 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
259 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 359, 194, 228, STR_02BC_VEHICLE_DESIGN_NAMES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
260 |
{ WWT_6, RESIZE_NONE, 14, 20, 119, 207, 218, STR_02BD, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
261 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 108, 118, 208, 217, STR_0225, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
262 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 130, 349, 207, 218, STR_02C0_SAVE_CUSTOM_NAMES, STR_02C2_SAVE_CUSTOMIZED_VEHICLE}, |
0 | 263 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
264 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
265 |
{ WWT_6, RESIZE_NONE, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
266 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 338, 348, 119, 128, STR_0225, STR_OPTIONS_LANG_TIP}, |
298
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
267 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
268 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
269 |
{ WWT_6, RESIZE_NONE, 14, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
270 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 158, 168, 161, 170, STR_0225, STR_OPTIONS_RES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
271 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, |
0 | 272 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
273 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
274 |
{ WWT_6, RESIZE_NONE, 14, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
275 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 338, 348, 161, 170, STR_0225, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, |
0 | 276 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
277 |
{ WIDGETS_END}, |
0 | 278 |
}; |
279 |
||
280 |
static const WindowDesc _game_options_desc = { |
|
298
0123c0489940
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
281 |
WDP_CENTER, WDP_CENTER, 370, 239, |
0 | 282 |
WC_GAME_OPTIONS,0, |
2064
e6a2b42d0b15
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
283 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 284 |
_game_options_widgets, |
285 |
GameOptionsWndProc |
|
286 |
}; |
|
287 |
||
288 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
289 |
void ShowGameOptions(void) |
0 | 290 |
{ |
291 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
292 |
AllocateWindowDesc(&_game_options_desc); |
|
293 |
} |
|
294 |
||
295 |
typedef struct { |
|
296 |
int16 min; |
|
297 |
int16 max; |
|
298 |
int16 step; |
|
299 |
StringID str; |
|
300 |
} GameSettingData; |
|
301 |
||
302 |
static const GameSettingData _game_setting_info[] = { |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
303 |
{ 0, 7, 1, STR_NULL}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
304 |
{ 0, 3, 1, STR_6830_IMMEDIATE}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
305 |
{ 0, 2, 1, STR_6816_LOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
306 |
{ 0, 3, 1, STR_26816_NONE}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
307 |
{100, 500, 50, STR_NULL}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
308 |
{ 2, 4, 1, STR_NULL}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
309 |
{ 0, 2, 1, STR_6820_LOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
310 |
{ 0, 4, 1, STR_681B_VERY_SLOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
311 |
{ 0, 2, 1, STR_6820_LOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
312 |
{ 0, 2, 1, STR_6823_NONE}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
313 |
{ 0, 3, 1, STR_6826_X1_5}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
314 |
{ 0, 2, 1, STR_6820_LOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
315 |
{ 0, 3, 1, STR_682A_VERY_FLAT}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
316 |
{ 0, 3, 1, STR_VERY_LOW}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
317 |
{ 0, 1, 1, STR_682E_STEADY}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
318 |
{ 0, 1, 1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
319 |
{ 0, 1, 1, STR_6836_OFF}, |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
320 |
{ 0, 2, 1, STR_6839_PERMISSIVE}, |
0 | 321 |
}; |
322 |
||
536 | 323 |
static inline bool GetBitAndShift(uint32 *b) |
0 | 324 |
{ |
325 |
uint32 x = *b; |
|
326 |
*b >>= 1; |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
327 |
return HASBIT(x, 0); |
0 | 328 |
} |
329 |
||
1385
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
330 |
/* |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
331 |
A: competitors |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
332 |
B: start time in months / 3 |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
333 |
C: town count (2 = high, 0 = low) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
334 |
D: industry count (3 = high, 0 = none) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
335 |
E: inital loan / 1000 (in GBP) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
336 |
F: interest rate |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
337 |
G: running costs (0 = low, 2 = high) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
338 |
H: construction speed of competitors (0 = very slow, 4 = very fast) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
339 |
I: intelligence (0-2) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
340 |
J: breakdowns(0 = off, 2 = normal) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
341 |
K: subsidy multiplier (0 = 1.5, 3 = 4.0) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
342 |
L: construction cost (0-2) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
343 |
M: terrain type (0 = very flat, 3 = mountainous) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
344 |
N: amount of water (0 = very low, 3 = high) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
345 |
O: economy (0 = steady, 1 = fluctuating) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
346 |
P: Train reversing (0 = end of line + stations, 1 = end of line) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
347 |
Q: disasters |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
348 |
R: area restructuring (0 = permissive, 2 = hostile) |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
349 |
*/ |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
350 |
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* |
91d75432f81e
(svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents:
1363
diff
changeset
|
351 |
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
352 |
{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
353 |
{4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, //medium |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
354 |
{7, 0, 2, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, //hard |
0 | 355 |
}; |
356 |
||
357 |
void SetDifficultyLevel(int mode, GameOptions *gm_opt) |
|
358 |
{ |
|
359 |
int i; |
|
360 |
assert(mode <= 3); |
|
361 |
||
362 |
gm_opt->diff_level = mode; |
|
363 |
if (mode != 3) { // not custom |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
364 |
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) |
0 | 365 |
((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i]; |
366 |
} |
|
367 |
} |
|
368 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
369 |
extern void StartupEconomy(void); |
46
c9bdf1d58df6
(svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents:
42
diff
changeset
|
370 |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
371 |
enum { |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
372 |
GAMEDIFF_WND_TOP_OFFSET = 45, |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
373 |
GAMEDIFF_WND_ROWSIZE = 9 |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
374 |
}; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
375 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
376 |
// Temporary holding place of values in the difficulty window until 'Save' is clicked |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
377 |
static GameOptions _opt_mod_temp; |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
378 |
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
379 |
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
380 |
|
0 | 381 |
static void GameDifficultyWndProc(Window *w, WindowEvent *e) |
382 |
{ |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
383 |
switch (e->event) { |
1794
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
384 |
case WE_CREATE: /* Setup disabled buttons when creating window */ |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
385 |
// disable all other difficulty buttons during gameplay except for 'custom' |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
386 |
w->disabled_state = (_game_mode != GM_NORMAL) ? 0 : (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6); |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
387 |
|
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
388 |
if (_game_mode == GM_EDITOR) SETBIT(w->disabled_state, 7); |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
389 |
|
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
390 |
if (_networking) { |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
391 |
SETBIT(w->disabled_state, 7); // disable highscore chart in multiplayer |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
392 |
if (!_network_server) |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
393 |
SETBIT(w->disabled_state, 10); // Disable save-button in multiplayer (and if client) |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
394 |
} |
24b4239f2090
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
395 |
break; |
0 | 396 |
case WE_PAINT: { |
397 |
uint32 click_a, click_b, disabled; |
|
398 |
int i; |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
399 |
int y, value; |
0 | 400 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
401 |
w->click_state = (1 << 3) << _opt_mod_temp.diff_level; // have current difficulty button clicked |
0 | 402 |
DrawWindowWidgets(w); |
403 |
||
404 |
click_a = _difficulty_click_a; |
|
405 |
click_b = _difficulty_click_b; |
|
406 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
407 |
/* XXX - Disabled buttons in normal gameplay. Bitshifted for each button to see if |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
408 |
* that bit is set. If it is set, the button is disabled */ |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
409 |
disabled = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0; |
0 | 410 |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
411 |
y = GAMEDIFF_WND_TOP_OFFSET; |
0 | 412 |
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) { |
4437
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4431
diff
changeset
|
413 |
DrawFrameRect( 5, y, 5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? FR_LOWERED : 0); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4431
diff
changeset
|
414 |
DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? FR_LOWERED : 0); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
415 |
if (GetBitAndShift(&disabled) || (_networking && !_network_server)) { |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
416 |
int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2]; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
417 |
GfxFillRect( 6, y + 1, 6 + 8, y + 8, color); |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
418 |
GfxFillRect(16, y + 1, 16 + 8, y + 8, color); |
0 | 419 |
} |
420 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
421 |
DrawStringCentered(10, y, STR_6819, 0); |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
422 |
DrawStringCentered(20, y, STR_681A, 0); |
0 | 423 |
|
424 |
||
425 |
value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i]; |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
426 |
if (i == 4) value *= 1000; // XXX - handle currency option |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
427 |
SetDParam(0, value); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
428 |
DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, 0); |
0 | 429 |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
430 |
y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit |
0 | 431 |
} |
432 |
} break; |
|
433 |
||
434 |
case WE_CLICK: |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
435 |
switch (e->click.widget) { |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
436 |
case 8: { /* Difficulty settings widget, decode click */ |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
437 |
const GameSettingData *info; |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
438 |
int x, y; |
0 | 439 |
uint btn, dis; |
440 |
int val; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
441 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
442 |
// Don't allow clients to make any changes |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
443 |
if (_networking && !_network_server) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
444 |
return; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
445 |
|
0 | 446 |
x = e->click.pt.x - 5; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
447 |
if (!IS_INT_INSIDE(x, 0, 21)) // Button area |
0 | 448 |
return; |
449 |
||
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
450 |
y = e->click.pt.y - GAMEDIFF_WND_TOP_OFFSET; |
0 | 451 |
if (y < 0) |
452 |
return; |
|
453 |
||
454 |
// Get button from Y coord. |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
455 |
btn = y / (GAMEDIFF_WND_ROWSIZE + 2); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
456 |
if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) |
0 | 457 |
return; |
458 |
||
459 |
// Clicked disabled button? |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
460 |
dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
461 |
|
0 | 462 |
if (HASBIT(dis, btn)) |
463 |
return; |
|
464 |
||
465 |
_difficulty_timeout = 5; |
|
466 |
||
467 |
val = ((int*)&_opt_mod_temp.diff)[btn]; |
|
468 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
469 |
info = &_game_setting_info[btn]; // get information about the difficulty setting |
0 | 470 |
if (x >= 10) { |
471 |
// Increase button clicked |
|
472 |
val = min(val + info->step, info->max); |
|
473 |
SETBIT(_difficulty_click_b, btn); |
|
474 |
} else { |
|
475 |
// Decrease button clicked |
|
476 |
val = max(val - info->step, info->min); |
|
477 |
SETBIT(_difficulty_click_a, btn); |
|
478 |
} |
|
479 |
||
480 |
// save value in temporary variable |
|
481 |
((int*)&_opt_mod_temp.diff)[btn] = val; |
|
482 |
SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom |
|
483 |
SetWindowDirty(w); |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
484 |
} break; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
485 |
case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */ |
0 | 486 |
// temporarily change difficulty level |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
487 |
SetDifficultyLevel(e->click.widget - 3, &_opt_mod_temp); |
0 | 488 |
SetWindowDirty(w); |
489 |
break; |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
490 |
case 7: /* Highscore Table */ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
491 |
ShowHighscoreTable(_opt_mod_temp.diff_level, -1); |
0 | 492 |
break; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
493 |
case 10: { /* Save button - save changes */ |
0 | 494 |
int btn, val; |
495 |
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) { |
|
496 |
val = ((int*)&_opt_mod_temp.diff)[btn]; |
|
497 |
// if setting has changed, change it |
|
1501
0fc808b4e375
(svn r2005) - Fix: fix previous commit. Using 'New Game (scenario)' will use YOUR difficulty settings but ingame options (eg townnames, currency). Also settings are correctly saved when closing the difficulty window now.
Darkvater
parents:
1500
diff
changeset
|
498 |
if (val != ((int*)&_opt_ptr->diff)[btn]) |
0 | 499 |
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
500 |
} |
|
501 |
DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
502 |
DeleteWindow(w); |
|
42
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
503 |
// 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
|
504 |
// 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
|
505 |
// are loaded correctly. |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
506 |
if (_game_mode == GM_EDITOR) |
567add3568d6
(svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents:
26
diff
changeset
|
507 |
StartupEconomy(); |
0 | 508 |
break; |
509 |
} |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
510 |
case 11: /* Cancel button - close window, abandon changes */ |
0 | 511 |
DeleteWindow(w); |
512 |
break; |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
513 |
} break; |
0 | 514 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
515 |
case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */ |
0 | 516 |
if (_difficulty_timeout != 0 && !--_difficulty_timeout) { |
517 |
_difficulty_click_a = 0; |
|
518 |
_difficulty_click_b = 0; |
|
519 |
SetWindowDirty(w); |
|
520 |
} |
|
521 |
break; |
|
522 |
} |
|
523 |
} |
|
524 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
525 |
#undef DIFF_INGAME_DISABLED_BUTTONS |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
526 |
|
0 | 527 |
static const Widget _game_difficulty_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
528 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
529 |
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
530 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 29, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
531 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_6801_EASY, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
532 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_6802_MEDIUM, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
533 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_6803_HARD, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
534 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_6804_CUSTOM, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
535 |
{ WWT_TEXTBTN, RESIZE_NONE, 10, 0, 369, 30, 41, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
536 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 262, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
537 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 263, 278, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
538 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 105, 185, 265, 276, STR_OPTIONS_SAVE_CHANGES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
539 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 186, 266, 265, 276, STR_012E_CANCEL, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
540 |
{ WIDGETS_END}, |
0 | 541 |
}; |
542 |
||
543 |
static const WindowDesc _game_difficulty_desc = { |
|
544 |
WDP_CENTER, WDP_CENTER, 370, 279, |
|
545 |
WC_GAME_OPTIONS,0, |
|
546 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
547 |
_game_difficulty_widgets, |
|
548 |
GameDifficultyWndProc |
|
549 |
}; |
|
550 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
551 |
void ShowGameDifficulty(void) |
0 | 552 |
{ |
553 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
554 |
/* Copy current settings (ingame or in intro) to temporary holding place |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
555 |
* change that when setting stuff, copy back on clicking 'OK' */ |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
556 |
memcpy(&_opt_mod_temp, _opt_ptr, sizeof(GameOptions)); |
0 | 557 |
AllocateWindowDesc(&_game_difficulty_desc); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
558 |
} |
0 | 559 |
|
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
560 |
static const char *_patches_ui[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
561 |
"vehicle_speed", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
562 |
"status_long_date", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
563 |
"show_finances", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
564 |
"autoscroll", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
565 |
"reverse_scroll", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
566 |
"errmsg_duration", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
567 |
"toolbar_pos", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
568 |
"window_snap_radius", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
569 |
"invisible_trees", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
570 |
"population_in_label", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
571 |
"link_terraform_toolbar", |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
572 |
"progress_update_interval", |
21 | 573 |
}; |
574 |
||
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
575 |
static const char *_patches_construction[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
576 |
"build_on_slopes", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
577 |
"extra_dynamite", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
578 |
"longbridges", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
579 |
"signal_side", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
580 |
"always_small_airport", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
581 |
"drag_signals_density", |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
582 |
"oil_refinery_limit", |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
583 |
}; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
584 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
585 |
static const char *_patches_stations[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
586 |
"join_stations", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
587 |
"full_load_any", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
588 |
"improved_load", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
589 |
"selectgoods", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
590 |
"new_nonstop", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
591 |
"nonuniform_stations", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
592 |
"station_spread", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
593 |
"serviceathelipad", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
594 |
"modified_catchment", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
595 |
}; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
596 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
597 |
static const char *_patches_economy[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
598 |
"inflation", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
599 |
"build_rawmaterial_ind", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
600 |
"multiple_industry_per_town", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
601 |
"same_industry_close", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
602 |
"bribe", |
4285
19cb745c694e
(svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents:
4261
diff
changeset
|
603 |
"colored_news_year", |
19cb745c694e
(svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents:
4261
diff
changeset
|
604 |
"ending_year", |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
605 |
"smooth_economy", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
606 |
"allow_shares", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
607 |
}; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
608 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
609 |
static const char *_patches_ai[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
610 |
"ainew_active", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
611 |
"ai_in_multiplayer", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
612 |
"ai_disable_veh_train", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
613 |
"ai_disable_veh_roadveh", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
614 |
"ai_disable_veh_aircraft", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
615 |
"ai_disable_veh_ship", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
616 |
}; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
617 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
618 |
static const char *_patches_vehicles[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
619 |
"realistic_acceleration", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
620 |
"forbid_90_deg", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
621 |
"mammoth_trains", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
622 |
"gotodepot", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
623 |
"roadveh_queue", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
624 |
"new_pathfinding_all", |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3888
diff
changeset
|
625 |
"yapf.ship_use_yapf", |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3888
diff
changeset
|
626 |
"yapf.road_use_yapf", |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3888
diff
changeset
|
627 |
"yapf.rail_use_yapf", |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
628 |
"train_income_warn", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
629 |
"order_review_system", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
630 |
"never_expire_vehicles", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
631 |
"lost_train_days", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
632 |
"autorenew", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
633 |
"autorenew_months", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
634 |
"autorenew_money", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
635 |
"max_trains", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
636 |
"max_roadveh", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
637 |
"max_aircraft", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
638 |
"max_ships", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
639 |
"servint_ispercent", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
640 |
"servint_trains", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
641 |
"servint_roadveh", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
642 |
"servint_ships", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
643 |
"servint_aircraft", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
644 |
"no_servicing_if_no_breakdowns", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
645 |
"wagon_speed_limits", |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
646 |
}; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
647 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
648 |
typedef struct PatchEntry { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
649 |
const SettingDesc *setting; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
650 |
uint index; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
651 |
} PatchEntry; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
652 |
|
0 | 653 |
typedef struct PatchPage { |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
654 |
const char **names; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
655 |
PatchEntry *entries; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
656 |
byte num; |
0 | 657 |
} PatchPage; |
658 |
||
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
659 |
/* PatchPage holds the categories, the number of elements in each category |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
660 |
* and (in NULL) a dynamic array of settings based on the string-representations |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
661 |
* of the settings. This way there is no worry about indeces, and such */ |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
662 |
static PatchPage _patches_page[] = { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
663 |
{_patches_ui, NULL, lengthof(_patches_ui)}, |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
664 |
{_patches_construction, NULL, lengthof(_patches_construction)}, |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
665 |
{_patches_vehicles, NULL, lengthof(_patches_vehicles)}, |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
666 |
{_patches_stations, NULL, lengthof(_patches_stations)}, |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
667 |
{_patches_economy, NULL, lengthof(_patches_economy)}, |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
668 |
{_patches_ai, NULL, lengthof(_patches_ai)}, |
0 | 669 |
}; |
670 |
||
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
671 |
/** The main patches window. Shows a number of categories on top and |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
672 |
* a selection of patches in that category. |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
673 |
* Uses WP(w, def_d) macro - data_1, data_2, data_3 */ |
0 | 674 |
static void PatchesSelectionWndProc(Window *w, WindowEvent *e) |
675 |
{ |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
676 |
static Patches *patches_ptr; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
677 |
|
1741
628182f1bbd2
(svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents:
1739
diff
changeset
|
678 |
switch (e->event) { |
3206
00fef2d4d301
(svn r3874) - Codechange: move the extern decleration of _patches_newgame inside the WE_CREATE event because it is only used there.
Darkvater
parents:
3131
diff
changeset
|
679 |
case WE_CREATE: { |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
680 |
static bool first_time = true; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
681 |
|
3121
72fb0554f9f1
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents:
3119
diff
changeset
|
682 |
patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches; |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
683 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
684 |
/* Build up the dynamic settings-array only once per OpenTTD session */ |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
685 |
if (first_time) { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
686 |
PatchPage *page; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
687 |
for (page = &_patches_page[0]; page != endof(_patches_page); page++) { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
688 |
uint i; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
689 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
690 |
page->entries = malloc(page->num * sizeof(*page->entries)); |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
691 |
for (i = 0; i != page->num; i++) { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
692 |
uint index; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
693 |
const SettingDesc *sd = GetPatchFromName(page->names[i], &index); |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
694 |
assert(sd != NULL); |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
695 |
|
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
696 |
page->entries[i].setting = sd; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
697 |
page->entries[i].index = index; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
698 |
} |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
699 |
} |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
700 |
first_time = false; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
701 |
} |
3206
00fef2d4d301
(svn r3874) - Codechange: move the extern decleration of _patches_newgame inside the WE_CREATE event because it is only used there.
Darkvater
parents:
3131
diff
changeset
|
702 |
} break; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
703 |
|
0 | 704 |
case WE_PAINT: { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
705 |
int x, y; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
706 |
const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; |
2639 | 707 |
uint i; |
0 | 708 |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
709 |
/* Set up selected category */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
710 |
w->click_state = 1 << (WP(w, def_d).data_1 + 4); |
0 | 711 |
DrawWindowWidgets(w); |
712 |
||
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
713 |
x = 5; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
714 |
y = 47; |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
715 |
for (i = 0; i != page->num; i++) { |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
716 |
const SettingDesc *sd = page->entries[i].setting; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
717 |
const SettingDescBase *sdb = &sd->desc; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
718 |
const void *var = ini_get_variable(&sd->save, patches_ptr); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
719 |
bool editable = true; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
720 |
bool disabled = false; |
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
721 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
722 |
// We do not allow changes of some items when we are a client in a networkgame |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
723 |
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
724 |
if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
725 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
726 |
if (sdb->cmd == SDT_BOOLX) { |
3124
cf624337b649
(svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents:
3121
diff
changeset
|
727 |
static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}}; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
728 |
/* Draw checkbox for boolean-value either on/off */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
729 |
bool on = (*(bool*)var); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
730 |
|
3124
cf624337b649
(svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents:
3121
diff
changeset
|
731 |
DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : 0); |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
732 |
SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
0 | 733 |
} else { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
734 |
int32 value; |
0 | 735 |
|
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
736 |
value = (int32)ReadValue(var, sd->save.conv); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
737 |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
738 |
/* Draw [<][>] boxes for settings of an integer-type */ |
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
739 |
DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
740 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
741 |
disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); |
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
|
742 |
if (disabled) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
743 |
SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
0 | 744 |
} else { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
745 |
if (sdb->flags & SGF_CURRENCY) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
523
diff
changeset
|
746 |
SetDParam(0, STR_CONFIG_PATCHES_CURRENCY); |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
747 |
} else if (sdb->flags & SGF_MULTISTRING) { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
748 |
SetDParam(0, sdb->str + value + 1); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
749 |
} else { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
750 |
SetDParam(0, (sdb->flags & SGF_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
|
751 |
} |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
752 |
SetDParam(1, value); |
0 | 753 |
} |
754 |
} |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
755 |
DrawString(30, y, (sdb->str) + disabled, 0); |
0 | 756 |
y += 11; |
757 |
} |
|
758 |
break; |
|
759 |
} |
|
760 |
||
761 |
case WE_CLICK: |
|
2952 | 762 |
switch (e->click.widget) { |
0 | 763 |
case 3: { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
764 |
const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
765 |
const SettingDesc *sd; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
766 |
void *var; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
767 |
int32 value; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
768 |
int x, y; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
769 |
byte btn; |
0 | 770 |
|
771 |
y = e->click.pt.y - 46 - 1; |
|
772 |
if (y < 0) return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
773 |
|
0 | 774 |
x = e->click.pt.x - 5; |
775 |
if (x < 0) return; |
|
776 |
||
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
777 |
btn = y / 11; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
778 |
if (y % 11 > 9) return; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
779 |
if (btn >= page->num) return; |
0 | 780 |
|
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
781 |
sd = page->entries[btn].setting; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
782 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
783 |
/* return if action is only active in network, or only settable by server */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
784 |
if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
785 |
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
786 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
787 |
var = ini_get_variable(&sd->save, patches_ptr); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
788 |
value = (int32)ReadValue(var, sd->save.conv); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
789 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
790 |
/* clicked on the icon on the left side. Either scroller or bool on/off */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
791 |
if (x < 21) { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
792 |
const SettingDescBase *sdb = &sd->desc; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
793 |
int32 oldvalue = value; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
794 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
795 |
switch (sdb->cmd) { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
796 |
case SDT_BOOLX: value ^= 1; break; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
797 |
case SDT_NUMX: { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
798 |
/* Add a dynamic step-size to the scroller. In a maximum of |
4431
7ecf73508c31
(svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents:
4377
diff
changeset
|
799 |
* 50-steps you should be able to get from min to max, |
7ecf73508c31
(svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents:
4377
diff
changeset
|
800 |
* unless specified otherwise in the 'interval' variable |
7ecf73508c31
(svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents:
4377
diff
changeset
|
801 |
* of the current patch. */ |
7ecf73508c31
(svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents:
4377
diff
changeset
|
802 |
uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
803 |
if (step == 0) step = 1; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
804 |
|
0 | 805 |
// don't allow too fast scrolling |
806 |
if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) { |
|
807 |
_left_button_clicked = false; |
|
808 |
return; |
|
809 |
} |
|
810 |
||
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
811 |
/* Increase or decrease the value and clamp it to extremes */ |
0 | 812 |
if (x >= 10) { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
813 |
value += step; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
814 |
if (value > sdb->max) value = sdb->max; |
0 | 815 |
} else { |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
816 |
value -= step; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
817 |
if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; |
0 | 818 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
819 |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
820 |
/* Set up scroller timeout */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
821 |
if (value != oldvalue) { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
822 |
WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); |
0 | 823 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
824 |
_left_button_clicked = false; |
|
825 |
} |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
826 |
} break; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
827 |
default: NOT_REACHED(); |
0 | 828 |
} |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
829 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
830 |
if (value != oldvalue) { |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
831 |
SetPatchValue(page->entries[btn].index, patches_ptr, value); |
0 | 832 |
SetWindowDirty(w); |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
833 |
if (sdb->proc != NULL) sdb->proc((int32)ReadValue(var, sd->save.conv)); |
0 | 834 |
} |
835 |
} else { |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
836 |
/* only open editbox for types that its sensible for */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
837 |
if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
838 |
/* Show the correct currency-translated value */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
839 |
if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
840 |
|
0 | 841 |
WP(w,def_d).data_3 = btn; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
842 |
SetDParam(0, value); |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4286
diff
changeset
|
843 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0, CS_NUMERAL); |
0 | 844 |
} |
845 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
846 |
|
0 | 847 |
break; |
848 |
} |
|
21 | 849 |
case 4: case 5: case 6: case 7: case 8: case 9: |
0 | 850 |
WP(w,def_d).data_1 = e->click.widget - 4; |
851 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
852 |
SetWindowDirty(w); |
|
853 |
break; |
|
854 |
} |
|
855 |
break; |
|
856 |
||
857 |
case WE_TIMEOUT: |
|
858 |
WP(w,def_d).data_2 = 0; |
|
859 |
SetWindowDirty(w); |
|
860 |
break; |
|
861 |
||
862 |
case WE_ON_EDIT_TEXT: { |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
863 |
if (e->edittext.str != NULL) { |
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
864 |
const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3]; |
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
865 |
const SettingDesc *sd = pe->setting; |
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
866 |
void *var = ini_get_variable(&sd->save, patches_ptr); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
867 |
int32 value = atoi(e->edittext.str); |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
868 |
|
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
869 |
/* Save the correct currency-translated value */ |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
870 |
if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; |
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
871 |
|
3247
ede7a53941b2
(svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents:
3206
diff
changeset
|
872 |
SetPatchValue(pe->index, patches_ptr, value); |
0 | 873 |
SetWindowDirty(w); |
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
67
diff
changeset
|
874 |
|
3118
adc86793eee1
(svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents:
3107
diff
changeset
|
875 |
if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv)); |
0 | 876 |
} |
877 |
break; |
|
878 |
} |
|
879 |
||
880 |
case WE_DESTROY: |
|
881 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
882 |
break; |
|
883 |
} |
|
884 |
} |
|
885 |
||
886 |
static const Widget _patches_selection_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
887 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
888 |
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
889 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
890 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 360, 0x0, STR_NULL}, |
0 | 891 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
892 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
893 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
894 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
895 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
896 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
897 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 28, 39, STR_CONFIG_PATCHES_AI, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
898 |
{ WIDGETS_END}, |
0 | 899 |
}; |
900 |
||
901 |
static const WindowDesc _patches_selection_desc = { |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3888
diff
changeset
|
902 |
WDP_CENTER, WDP_CENTER, 370, 361, |
0 | 903 |
WC_GAME_OPTIONS,0, |
904 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
905 |
_patches_selection_widgets, |
|
906 |
PatchesSelectionWndProc, |
|
907 |
}; |
|
908 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
909 |
void ShowPatchesSelection(void) |
0 | 910 |
{ |
911 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
912 |
AllocateWindowDesc(&_patches_selection_desc); |
|
913 |
} |
|
478
3a161108a15d
(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
|
914 |
|
484 | 915 |
enum { |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
916 |
NEWGRF_WND_PROC_OFFSET_TOP_WIDGET = 14, |
484 | 917 |
NEWGRF_WND_PROC_ROWSIZE = 14 |
918 |
}; |
|
478
3a161108a15d
(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
|
919 |
|
3a161108a15d
(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
|
920 |
static void NewgrfWndProc(Window *w, WindowEvent *e) |
3a161108a15d
(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
|
921 |
{ |
1741
628182f1bbd2
(svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents:
1739
diff
changeset
|
922 |
static GRFFile *_sel_grffile; |
484 | 923 |
switch (e->event) { |
478
3a161108a15d
(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
|
924 |
case WE_PAINT: { |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
925 |
int x, y = NEWGRF_WND_PROC_OFFSET_TOP_WIDGET; |
484 | 926 |
uint16 i = 0; |
1477 | 927 |
GRFFile *c = _first_grffile; |
478
3a161108a15d
(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
|
928 |
|
3a161108a15d
(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
|
929 |
DrawWindowWidgets(w); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
930 |
|
484 | 931 |
if (_first_grffile == NULL) { // no grf sets installed |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
932 |
DrawStringMultiCenter(140, 210, STR_NEWGRF_NO_FILES_INSTALLED, 250); |
478
3a161108a15d
(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
|
933 |
break; |
3a161108a15d
(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
|
934 |
} |
3a161108a15d
(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
|
935 |
|
3a161108a15d
(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
|
936 |
// draw list of all grf files |
484 | 937 |
while (c != NULL) { |
938 |
if (i >= w->vscroll.pos) { // draw files according to scrollbar position |
|
2639 | 939 |
bool h = (_sel_grffile == c); |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
940 |
// show highlighted item with a different background and highlighted text |
2639 | 941 |
if (h) GfxFillRect(1, y + 1, 267, y + 12, 156); |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
942 |
// XXX - will be grf name later |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
943 |
DoDrawString(c->filename, 25, y + 2, h ? 0xC : 0x10); |
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
944 |
DrawSprite(SPRITE_PALETTE(SPR_SQUARE | PALETTE_TO_RED), 5, y + 2); |
484 | 945 |
y += NEWGRF_WND_PROC_ROWSIZE; |
478
3a161108a15d
(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
|
946 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
947 |
|
484 | 948 |
c = c->next; |
949 |
if (++i == w->vscroll.cap + w->vscroll.pos) break; // stop after displaying 12 items |
|
478
3a161108a15d
(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
|
950 |
} |
3a161108a15d
(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
|
951 |
|
3a161108a15d
(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
|
952 |
// DoDrawString(_sel_grffile->setname, 120, 200, 0x01); // draw grf name |
3a161108a15d
(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
|
953 |
|
484 | 954 |
if (_sel_grffile == NULL) { // no grf file selected yet |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
955 |
DrawStringMultiCenter(140, 210, STR_NEWGRF_TIP, 250); |
478
3a161108a15d
(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
|
956 |
} else { |
3a161108a15d
(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
|
957 |
// draw filename |
484 | 958 |
x = DrawString(5, 199, STR_NEWGRF_FILENAME, 0); |
959 |
DoDrawString(_sel_grffile->filename, x + 2, 199, 0x01); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
960 |
|
478
3a161108a15d
(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
|
961 |
// draw grf id |
484 | 962 |
x = DrawString(5, 209, STR_NEWGRF_GRF_ID, 0); |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3596
diff
changeset
|
963 |
snprintf(_userstring, lengthof(_userstring), "%08X", BSWAP32(_sel_grffile->grfid)); |
486
e81a0c19c503
(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
|
964 |
DrawString(x + 2, 209, STR_SPEC_USERSTRING, 0x01); |
478
3a161108a15d
(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
|
965 |
} |
484 | 966 |
} break; |
478
3a161108a15d
(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
|
967 |
|
3a161108a15d
(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
|
968 |
case WE_CLICK: |
2952 | 969 |
switch (e->click.widget) { |
982
d3ce4d6a65f8
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
970
diff
changeset
|
970 |
case 3: { // select a grf file |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
971 |
int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE; |
478
3a161108a15d
(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
|
972 |
|
2549 | 973 |
if (y >= w->vscroll.cap) return; // click out of bounds |
478
3a161108a15d
(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
|
974 |
|
484 | 975 |
y += w->vscroll.pos; |
976 |
||
2766
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
977 |
if (y >= w->vscroll.count) return; |
478
3a161108a15d
(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
|
978 |
|
3a161108a15d
(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
|
979 |
_sel_grffile = _first_grffile; |
484 | 980 |
// get selected grf-file |
981 |
while (y-- != 0) _sel_grffile = _sel_grffile->next; |
|
982 |
||
478
3a161108a15d
(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
|
983 |
SetWindowDirty(w); |
484 | 984 |
} break; |
985 |
case 9: /* Cancel button */ |
|
478
3a161108a15d
(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
|
986 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
3a161108a15d
(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
|
987 |
break; |
3a161108a15d
(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
|
988 |
} break; |
3a161108a15d
(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
|
989 |
|
3a161108a15d
(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
|
990 |
/* Parameter edit box not used yet |
3a161108a15d
(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
|
991 |
case WE_TIMEOUT: |
3a161108a15d
(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
|
992 |
WP(w,def_d).data_2 = 0; |
3a161108a15d
(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
|
993 |
SetWindowDirty(w); |
3a161108a15d
(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
|
994 |
break; |
3a161108a15d
(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
|
995 |
|
3a161108a15d
(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
|
996 |
case WE_ON_EDIT_TEXT: { |
3a161108a15d
(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
|
997 |
if (*e->edittext.str) { |
3a161108a15d
(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
|
998 |
SetWindowDirty(w); |
3a161108a15d
(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
|
999 |
} |
3a161108a15d
(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
|
1000 |
break; |
3a161108a15d
(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
|
1001 |
} |
3a161108a15d
(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
|
1002 |
*/ |
3a161108a15d
(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
|
1003 |
case WE_DESTROY: |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1004 |
_sel_grffile = NULL; |
478
3a161108a15d
(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
|
1005 |
DeleteWindowById(WC_QUERY_STRING, 0); |
3a161108a15d
(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
|
1006 |
break; |
3a161108a15d
(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
|
1007 |
} |
3a161108a15d
(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
|
1008 |
} |
3a161108a15d
(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
|
1009 |
|
3a161108a15d
(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
|
1010 |
static const Widget _newgrf_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1011 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1012 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1013 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 279, 183, 276, 0x0, STR_NULL}, |
478
3a161108a15d
(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
|
1014 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1015 |
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 267, 14, 182, 0xC01, /*small rows*/ STR_NEWGRF_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1016 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 268, 279, 14, 182, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
478
3a161108a15d
(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
|
1017 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1018 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 147, 158, 244, 255, STR_0188, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1019 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 159, 170, 244, 255, STR_0189, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1020 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 175, 274, 244, 255, STR_NEWGRF_SET_PARAMETERS, STR_NULL}, |
484 | 1021 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1022 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 5, 138, 261, 272, STR_NEWGRF_APPLY_CHANGES, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1023 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 142, 274, 261, 272, STR_012E_CANCEL, STR_NULL}, |
478
3a161108a15d
(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
|
1024 |
{ WIDGETS_END}, |
3a161108a15d
(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
|
1025 |
}; |
3a161108a15d
(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
|
1026 |
|
3a161108a15d
(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
|
1027 |
static const WindowDesc _newgrf_desc = { |
502
defb8fd8fc98
(svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents:
486
diff
changeset
|
1028 |
WDP_CENTER, WDP_CENTER, 280, 277, |
478
3a161108a15d
(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
|
1029 |
WC_GAME_OPTIONS,0, |
1015
3629f5e8c092
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
998
diff
changeset
|
1030 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
478
3a161108a15d
(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
|
1031 |
_newgrf_widgets, |
3a161108a15d
(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
|
1032 |
NewgrfWndProc, |
3a161108a15d
(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
|
1033 |
}; |
3a161108a15d
(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
|
1034 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1037
diff
changeset
|
1035 |
void ShowNewgrf(void) |
478
3a161108a15d
(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
|
1036 |
{ |
2766
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1037 |
const GRFFile* c; |
478
3a161108a15d
(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
|
1038 |
Window *w; |
2766
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1039 |
uint count; |
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1040 |
|
478
3a161108a15d
(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
|
1041 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
3a161108a15d
(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
|
1042 |
w = AllocateWindowDesc(&_newgrf_desc); |
3a161108a15d
(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
|
1043 |
|
2766
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1044 |
count = 0; |
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1045 |
for (c = _first_grffile; c != NULL; c = c->next) count++; |
478
3a161108a15d
(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
|
1046 |
|
3a161108a15d
(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
|
1047 |
w->vscroll.cap = 12; |
2766
3a33fe670d29
(svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents:
2749
diff
changeset
|
1048 |
w->vscroll.count = count; |
478
3a161108a15d
(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
|
1049 |
w->vscroll.pos = 0; |
3a161108a15d
(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
|
1050 |
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7); |
3a161108a15d
(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
|
1051 |
} |
3a161108a15d
(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
|
1052 |
|
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1053 |
/** |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1054 |
* Draw [<][>] boxes. |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1055 |
* @param x the x position to draw |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1056 |
* @param y the y position to draw |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1057 |
* @param ctab the color of the buttons |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1058 |
* @param state 0 = none clicked, 1 = first clicked, 2 = second clicked |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1059 |
* @param clickable_left is the left button clickable? |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1060 |
* @param clickable_right is the right button clickable? |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1061 |
*/ |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1062 |
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right) |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1063 |
{ |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
1064 |
int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2]; |
3107
d743cfa2d832
(svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.
Darkvater
parents:
2952
diff
changeset
|
1065 |
|
4211
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1066 |
DrawFrameRect(x, y + 1, x + 9, y + 9, ctab, (state == 1) ? FR_LOWERED : 0); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1067 |
DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : 0); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1068 |
DrawStringCentered(x + 5, y + 1, STR_6819, 0); // [<] |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1069 |
DrawStringCentered(x + 15, y + 1, STR_681A, 0); // [>] |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1070 |
|
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1071 |
/* Grey out the buttons that aren't clickable */ |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1072 |
if (!clickable_left) |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1073 |
GfxFillRect(x + 1, y + 1, x + 1 + 8, y + 8, color); |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1074 |
if (!clickable_right) |
5ee54ab361c9
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1075 |
GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color); |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1076 |
} |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1077 |
|
2307
484c654dc875
(svn r2831) Fix some potential and real buffer overflows
tron
parents:
2306
diff
changeset
|
1078 |
static char _str_separator[2]; |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1079 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1080 |
static void CustCurrencyWndProc(Window *w, WindowEvent *e) |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1081 |
{ |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1082 |
switch (e->event) { |
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1083 |
case WE_PAINT: { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1084 |
int x; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1085 |
int y = 20; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1086 |
int clk = WP(w,def_d).data_1; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1087 |
DrawWindowWidgets(w); |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1088 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1089 |
// exchange rate |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1090 |
DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1091 |
SetDParam(0, 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1092 |
SetDParam(1, 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1093 |
DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1094 |
y += 12; |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1095 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1096 |
// separator |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1097 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1098 |
x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1099 |
DoDrawString(_str_separator, x + 4, y + 1, 6); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1100 |
y += 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1101 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1102 |
// prefix |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1103 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1104 |
x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1105 |
DoDrawString(_custom_currency.prefix, x + 4, y + 1, 6); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1106 |
y += 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1107 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1108 |
// suffix |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1109 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1110 |
x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1111 |
DoDrawString(_custom_currency.suffix, x + 4, y + 1, 6); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1112 |
y += 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1113 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1114 |
// switch to euro |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1115 |
DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1116 |
SetDParam(0, _custom_currency.to_euro); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1117 |
DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1118 |
y += 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1119 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1120 |
// Preview |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1121 |
y += 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1122 |
SetDParam(0, 10000); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1123 |
DrawString(35, y + 1, STR_CURRENCY_PREVIEW, 0); |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1124 |
break; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1125 |
} |
812
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1126 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1127 |
case WE_CLICK: { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1128 |
int line = (e->click.pt.y - 20) / 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1129 |
int len = 0; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1130 |
int x = e->click.pt.x; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1131 |
StringID str = 0; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1132 |
CharSetFilter afilter = CS_ALPHANUMERAL; |
812
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1133 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1134 |
switch (line) { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1135 |
case 0: // rate |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1136 |
if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1137 |
if (x < 20) { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1138 |
if (_custom_currency.rate > 1) _custom_currency.rate--; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1139 |
WP(w,def_d).data_1 = 1 << (line * 2 + 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1140 |
} else { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1141 |
if (_custom_currency.rate < 5000) _custom_currency.rate++; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1142 |
WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1143 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1144 |
} else { // enter text |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1145 |
SetDParam(0, _custom_currency.rate); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1146 |
str = STR_CONFIG_PATCHES_INT32; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1147 |
len = 4; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1148 |
afilter = CS_NUMERAL; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1149 |
} |
2639 | 1150 |
break; |
1151 |
||
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1152 |
case 1: // separator |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1153 |
if (IS_INT_INSIDE(x, 10, 30)) { // clicked button |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1154 |
WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1155 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1156 |
str = BindCString(_str_separator); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1157 |
len = 1; |
2639 | 1158 |
break; |
1159 |
||
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1160 |
case 2: // prefix |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1161 |
if (IS_INT_INSIDE(x, 10, 30)) { // clicked button |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1162 |
WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1163 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1164 |
str = BindCString(_custom_currency.prefix); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1165 |
len = 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1166 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1167 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1168 |
case 3: // suffix |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1169 |
if (IS_INT_INSIDE(x, 10, 30)) { // clicked button |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1170 |
WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1171 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1172 |
str = BindCString(_custom_currency.suffix); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1173 |
len = 12; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1174 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1175 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1176 |
case 4: // to euro |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1177 |
if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1178 |
if (x < 20) { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1179 |
_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1180 |
CF_NOEURO : _custom_currency.to_euro - 1; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1181 |
WP(w,def_d).data_1 = 1 << (line * 2 + 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1182 |
} else { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1183 |
_custom_currency.to_euro = |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1184 |
clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1185 |
WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1186 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1187 |
} else { // enter text |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1188 |
SetDParam(0, _custom_currency.to_euro); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1189 |
str = STR_CONFIG_PATCHES_INT32; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1190 |
len = 4; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1191 |
afilter = CS_NUMERAL; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1192 |
} |
2639 | 1193 |
break; |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1194 |
} |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1195 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1196 |
if (len != 0) { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1197 |
WP(w,def_d).data_2 = line; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1198 |
ShowQueryString( |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1199 |
str, |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1200 |
STR_CURRENCY_CHANGE_PARAMETER, |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1201 |
len + 1, // maximum number of characters OR |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1202 |
250, // characters up to this width pixels, whichever is satisfied first |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1203 |
w->window_class, |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1204 |
w->window_number, afilter); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1205 |
} |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1206 |
|
4488
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1207 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1208 |
SetWindowDirty(w); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1209 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1210 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1211 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1212 |
case WE_ON_EDIT_TEXT: { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1213 |
const char *b = e->edittext.str; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1214 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1215 |
switch (WP(w,def_d).data_2) { |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1216 |
case 0: /* Exchange rate */ |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1217 |
_custom_currency.rate = clamp(atoi(b), 1, 5000); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1218 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1219 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1220 |
case 1: /* Thousands seperator */ |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1221 |
_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0]; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1222 |
ttd_strlcpy(_str_separator, b, lengthof(_str_separator)); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1223 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1224 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1225 |
case 2: /* Currency prefix */ |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1226 |
ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix)); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1227 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1228 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1229 |
case 3: /* Currency suffix */ |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1230 |
ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix)); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1231 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1232 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1233 |
case 4: { /* Year to switch to euro */ |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1234 |
int val = atoi(b); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1235 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1236 |
_custom_currency.to_euro = |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1237 |
(val < 2000 ? CF_NOEURO : min(val, MAX_YEAR)); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1238 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1239 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1240 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1241 |
MarkWholeScreenDirty(); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1242 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1243 |
} |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1244 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1245 |
case WE_TIMEOUT: |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1246 |
WP(w,def_d).data_1 = 0; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1247 |
SetWindowDirty(w); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1248 |
break; |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1249 |
|
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1250 |
case WE_DESTROY: |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1251 |
DeleteWindowById(WC_QUERY_STRING, 0); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1252 |
MarkWholeScreenDirty(); |
1be86990ea3e
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1253 |
break; |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1254 |
} |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1255 |
} |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1256 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1257 |
static const Widget _cust_currency_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1258 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1259 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 229, 0, 13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4300
diff
changeset
|
1260 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 229, 14, 119, 0x0, STR_NULL}, |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1261 |
{ WIDGETS_END}, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1262 |
}; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1263 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1264 |
static const WindowDesc _cust_currency_desc = { |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1265 |
WDP_CENTER, WDP_CENTER, 230, 120, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1266 |
WC_CUSTOM_CURRENCY, 0, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1267 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1268 |
_cust_currency_widgets, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1269 |
CustCurrencyWndProc, |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1270 |
}; |
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1271 |
|
2817 | 1272 |
static void ShowCustCurrency(void) |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1273 |
{ |
2306
adb71c055afb
(svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents:
2293
diff
changeset
|
1274 |
_str_separator[0] = _custom_currency.separator; |
1759
604a74a1e744
(svn r2263) - Fix: If the seperator string is empty for custom currencies, everything after that is cut off. Fix it by replacing nothing with ' '. Thanks for noticing peter1138
Darkvater
parents:
1756
diff
changeset
|
1275 |
_str_separator[1] = '\0'; |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1276 |
|
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1277 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
2639 | 1278 |
AllocateWindowDesc(&_cust_currency_desc); |
759
a445474d7c21
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1279 |
} |