author | glx |
Mon, 19 May 2008 15:13:58 +0000 | |
branch | noai |
changeset 10645 | 8cbdb511a674 |
parent 10513 | 33cb70ff2f5d |
child 10715 | 6bdf79ffb022 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
3 |
/** @file settings_gui.cpp GUI for settings. */ |
9574 | 4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1806
diff
changeset
|
6 |
#include "openttd.h" |
2291
2b064aa97f91
(svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents:
2231
diff
changeset
|
7 |
#include "currency.h" |
0 | 8 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "textbuf_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
11 |
#include "command_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9800
diff
changeset
|
12 |
#include "engine_func.h" |
430 | 13 |
#include "screenshot.h" |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
14 |
#include "newgrf.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5682
diff
changeset
|
15 |
#include "network/network.h" |
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
833
diff
changeset
|
16 |
#include "town.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2140
diff
changeset
|
17 |
#include "variables.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "settings_internal.h" |
9629 | 19 |
#include "newgrf_townname.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
20 |
#include "strings_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
21 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
22 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
#include "core/alloc_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
24 |
#include "string_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
25 |
#include "gfx_func.h" |
9732 | 26 |
#include "waypoint.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
27 |
#include "widgets/dropdown_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
28 |
#include "widgets/dropdown_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9800
diff
changeset
|
29 |
#include "station_func.h" |
0 | 30 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
31 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
32 |
#include "table/strings.h" |
0 | 33 |
|
3342
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
34 |
static const StringID _units_dropdown[] = { |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
35 |
STR_UNITS_IMPERIAL, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
36 |
STR_UNITS_METRIC, |
0de5e6997611
(svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents:
3247
diff
changeset
|
37 |
STR_UNITS_SI, |
0 | 38 |
INVALID_STRING_ID |
39 |
}; |
|
40 |
||
41 |
static const StringID _driveside_dropdown[] = { |
|
42 |
STR_02E9_DRIVE_ON_LEFT, |
|
43 |
STR_02EA_DRIVE_ON_RIGHT, |
|
44 |
INVALID_STRING_ID |
|
45 |
}; |
|
46 |
||
47 |
static const StringID _autosave_dropdown[] = { |
|
48 |
STR_02F7_OFF, |
|
49 |
STR_AUTOSAVE_1_MONTH, |
|
50 |
STR_02F8_EVERY_3_MONTHS, |
|
51 |
STR_02F9_EVERY_6_MONTHS, |
|
52 |
STR_02FA_EVERY_12_MONTHS, |
|
53 |
INVALID_STRING_ID, |
|
54 |
}; |
|
55 |
||
56 |
static const StringID _designnames_dropdown[] = { |
|
57 |
STR_02BE_DEFAULT, |
|
58 |
STR_02BF_CUSTOM, |
|
59 |
INVALID_STRING_ID |
|
60 |
}; |
|
61 |
||
62 |
static StringID *BuildDynamicDropdown(StringID base, int num) |
|
63 |
{ |
|
64 |
static StringID buf[32 + 1]; |
|
65 |
StringID *p = buf; |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10142
diff
changeset
|
66 |
while (--num >= 0) *p++ = base++; |
0 | 67 |
*p = INVALID_STRING_ID; |
68 |
return buf; |
|
69 |
} |
|
70 |
||
9629 | 71 |
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; |
72 |
static StringID *_grf_names = NULL; |
|
73 |
static int _nb_grf_names = 0; |
|
9626 | 74 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
75 |
void InitGRFTownGeneratorNames() |
9626 | 76 |
{ |
9629 | 77 |
free(_grf_names); |
78 |
_grf_names = GetGRFTownNameList(); |
|
79 |
_nb_grf_names = 0; |
|
80 |
for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++; |
|
81 |
} |
|
82 |
||
83 |
static inline StringID TownName(int town_name) |
|
84 |
{ |
|
85 |
if (town_name < _nb_orig_names) return STR_TOWNNAME_ORIGINAL_ENGLISH + town_name; |
|
86 |
town_name -= _nb_orig_names; |
|
87 |
if (town_name < _nb_grf_names) return _grf_names[town_name]; |
|
88 |
return STR_UNDEFINED; |
|
9626 | 89 |
} |
90 |
||
6573 | 91 |
static int GetCurRes() |
0 | 92 |
{ |
93 |
int i; |
|
2639 | 94 |
|
95 |
for (i = 0; i != _num_resolutions; i++) { |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
96 |
if (_resolutions[i][0] == _screen.width && |
2639 | 97 |
_resolutions[i][1] == _screen.height) { |
0 | 98 |
break; |
2639 | 99 |
} |
100 |
} |
|
0 | 101 |
return i; |
102 |
} |
|
103 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
104 |
enum GameOptionsWidgets { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
105 |
GAMEOPT_CURRENCY_BTN = 4, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
106 |
GAMEOPT_DISTANCE_BTN = 6, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
107 |
GAMEOPT_ROADSIDE_BTN = 8, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
108 |
GAMEOPT_TOWNNAME_BTN = 10, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
109 |
GAMEOPT_AUTOSAVE_BTN = 12, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
110 |
GAMEOPT_VEHICLENAME_BTN = 14, |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
111 |
GAMEOPT_VEHICLENAME_SAVE, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
112 |
GAMEOPT_LANG_BTN = 17, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
113 |
GAMEOPT_RESOLUTION_BTN = 19, |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
114 |
GAMEOPT_FULLSCREEN, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
115 |
GAMEOPT_SCREENSHOT_BTN = 22, |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
116 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
117 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
118 |
/** |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
119 |
* Update/redraw the townnames dropdown |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
120 |
* @param w the window the dropdown belongs to |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
121 |
* @param sel the currently selected townname generator |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
122 |
*/ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
123 |
static void ShowTownnameDropdown(Window *w, int sel) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
124 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
125 |
typedef std::map<StringID, int, StringIDCompare> TownList; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
126 |
TownList townnames; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
127 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
128 |
/* Add and sort original townnames generators */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
129 |
for (int i = 0; i < _nb_orig_names; i++) townnames[STR_TOWNNAME_ORIGINAL_ENGLISH + i] = i; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
130 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
131 |
/* Add and sort newgrf townnames generators */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
132 |
for (int i = 0; i < _nb_grf_names; i++) townnames[_grf_names[i]] = _nb_orig_names + i; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
133 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
134 |
DropDownList *list = new DropDownList(); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
135 |
for (TownList::iterator it = townnames.begin(); it != townnames.end(); it++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
136 |
list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || (*it).second == sel))); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
137 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
138 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
139 |
ShowDropDownList(w, list, sel, GAMEOPT_TOWNNAME_BTN); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
140 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
141 |
|
6573 | 142 |
static void ShowCustCurrency(); |
2817 | 143 |
|
10645 | 144 |
struct GameOptionsWindow : Window { |
145 |
GameOptionsWindow(const WindowDesc *desc) : Window(desc) |
|
146 |
{ |
|
147 |
this->FindWindowPlacementAndResize(desc); |
|
0 | 148 |
} |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
149 |
|
10645 | 150 |
~GameOptionsWindow() |
151 |
{ |
|
152 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
|
153 |
} |
|
0 | 154 |
|
10645 | 155 |
virtual void OnPaint() |
156 |
{ |
|
157 |
StringID str = STR_02BE_DEFAULT; |
|
1794
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1781
diff
changeset
|
158 |
|
10645 | 159 |
this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1)); |
160 |
if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM; |
|
161 |
SetDParam(0, str); |
|
162 |
SetDParam(1, _currency_specs[_opt_ptr->currency].name); |
|
163 |
SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units); |
|
164 |
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side); |
|
165 |
SetDParam(4, TownName(_opt_ptr->town_name)); |
|
166 |
SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]); |
|
167 |
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr); |
|
168 |
int i = GetCurRes(); |
|
169 |
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); |
|
170 |
SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); |
|
171 |
this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); |
|
172 |
||
173 |
this->DrawWidgets(); |
|
174 |
DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen |
|
0 | 175 |
} |
10645 | 176 |
|
177 |
virtual void OnClick(Point pt, int widget) |
|
178 |
{ |
|
179 |
switch (widget) { |
|
180 |
case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown |
|
181 |
ShowDropDownMenu(this, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0); |
|
182 |
break; |
|
183 |
||
184 |
case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown |
|
185 |
ShowDropDownMenu(this, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0); |
|
186 |
break; |
|
187 |
||
188 |
case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown |
|
189 |
int i = 0; |
|
190 |
extern bool RoadVehiclesAreBuilt(); |
|
191 |
||
192 |
/* You can only change the drive side if you are in the menu or ingame with |
|
193 |
* no vehicles present. In a networking game only the server can change it */ |
|
194 |
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) { |
|
195 |
i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value |
|
196 |
} |
|
197 |
||
198 |
ShowDropDownMenu(this, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0); |
|
199 |
} break; |
|
200 |
||
201 |
case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown |
|
202 |
ShowTownnameDropdown(this, _opt_ptr->town_name); |
|
203 |
break; |
|
204 |
||
205 |
case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown |
|
206 |
ShowDropDownMenu(this, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0); |
|
207 |
break; |
|
208 |
||
209 |
case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown |
|
210 |
ShowDropDownMenu(this, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0); |
|
211 |
break; |
|
212 |
||
213 |
case GAMEOPT_VEHICLENAME_SAVE: // Save customized vehicle-names to disk |
|
214 |
break; // not implemented |
|
215 |
||
216 |
case GAMEOPT_LANG_BTN: { // Setup interface language dropdown |
|
217 |
typedef std::map<StringID, int, StringIDCompare> LangList; |
|
218 |
||
219 |
/* Sort language names */ |
|
220 |
LangList langs; |
|
221 |
for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i; |
|
222 |
||
223 |
DropDownList *list = new DropDownList(); |
|
224 |
for (LangList::iterator it = langs.begin(); it != langs.end(); it++) { |
|
225 |
list->push_back(new DropDownListStringItem((*it).first, (*it).second, false)); |
|
226 |
} |
|
227 |
||
228 |
ShowDropDownList(this, list, _dynlang.curr, GAMEOPT_LANG_BTN); |
|
229 |
} break; |
|
230 |
||
231 |
case GAMEOPT_RESOLUTION_BTN: // Setup resolution dropdown |
|
232 |
ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0); |
|
233 |
break; |
|
234 |
||
235 |
case GAMEOPT_FULLSCREEN: // Click fullscreen on/off |
|
236 |
/* try to toggle full-screen on/off */ |
|
237 |
if (!ToggleFullScreen(!_fullscreen)) { |
|
238 |
ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0); |
|
239 |
} |
|
240 |
this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); |
|
241 |
this->SetDirty(); |
|
242 |
break; |
|
243 |
||
244 |
case GAMEOPT_SCREENSHOT_BTN: // Setup screenshot format dropdown |
|
245 |
ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0); |
|
246 |
break; |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
virtual void OnDropdownSelect(int widget, int index) |
|
251 |
{ |
|
252 |
switch (widget) { |
|
253 |
case GAMEOPT_VEHICLENAME_BTN: // Vehicle design names |
|
254 |
if (index == 0) { |
|
255 |
DeleteCustomEngineNames(); |
|
256 |
MarkWholeScreenDirty(); |
|
257 |
} else if (!(_vehicle_design_names & 1)) { |
|
258 |
LoadCustomEngineNames(); |
|
259 |
MarkWholeScreenDirty(); |
|
260 |
} |
|
261 |
break; |
|
262 |
||
263 |
case GAMEOPT_CURRENCY_BTN: /* Currency */ |
|
264 |
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); |
|
265 |
_opt_ptr->currency = index; |
|
266 |
MarkWholeScreenDirty(); |
|
267 |
break; |
|
268 |
||
269 |
case GAMEOPT_DISTANCE_BTN: // Measuring units |
|
270 |
_opt_ptr->units = index; |
|
271 |
MarkWholeScreenDirty(); |
|
272 |
break; |
|
273 |
||
274 |
case GAMEOPT_ROADSIDE_BTN: // Road side |
|
275 |
if (_opt_ptr->road_side != index) { // only change if setting changed |
|
276 |
DoCommandP(0, index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); |
|
277 |
MarkWholeScreenDirty(); |
|
278 |
} |
|
279 |
break; |
|
280 |
||
281 |
case GAMEOPT_TOWNNAME_BTN: // Town names |
|
282 |
if (_game_mode == GM_MENU) { |
|
283 |
_opt_ptr->town_name = index; |
|
284 |
InvalidateWindow(WC_GAME_OPTIONS, 0); |
|
285 |
} |
|
286 |
break; |
|
287 |
||
288 |
case GAMEOPT_AUTOSAVE_BTN: // Autosave options |
|
289 |
_opt.autosave = _opt_newgame.autosave = index; |
|
290 |
this->SetDirty(); |
|
291 |
break; |
|
292 |
||
293 |
case GAMEOPT_LANG_BTN: // Change interface language |
|
294 |
ReadLanguagePack(index); |
|
295 |
CheckForMissingGlyphsInLoadedLanguagePack(); |
|
296 |
UpdateAllStationVirtCoord(); |
|
297 |
UpdateAllWaypointSigns(); |
|
298 |
MarkWholeScreenDirty(); |
|
299 |
break; |
|
300 |
||
301 |
case GAMEOPT_RESOLUTION_BTN: // Change resolution |
|
302 |
if (index < _num_resolutions && ChangeResInGame(_resolutions[index][0], _resolutions[index][1])) { |
|
303 |
this->SetDirty(); |
|
304 |
} |
|
305 |
break; |
|
306 |
||
307 |
case GAMEOPT_SCREENSHOT_BTN: // Change screenshot format |
|
308 |
SetScreenshotFormat(index); |
|
309 |
this->SetDirty(); |
|
310 |
break; |
|
311 |
} |
|
312 |
} |
|
313 |
}; |
|
0 | 314 |
|
315 |
static const Widget _game_options_widgets[] = { |
|
4344
5d0e40cd67b9
(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
|
316 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(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
|
317 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(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
|
318 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 238, 0x0, STR_NULL}, |
5d0e40cd67b9
(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
|
319 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
320 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, |
4344
5d0e40cd67b9
(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
|
321 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
322 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION}, |
4344
5d0e40cd67b9
(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
|
323 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
324 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, |
4344
5d0e40cd67b9
(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
|
325 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
326 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, |
4344
5d0e40cd67b9
(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
|
327 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
328 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, |
0 | 329 |
|
4344
5d0e40cd67b9
(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
|
330 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 359, 194, 228, STR_02BC_VEHICLE_DESIGN_NAMES, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
331 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 119, 207, 218, STR_02BD, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, |
4344
5d0e40cd67b9
(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
|
332 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 130, 349, 207, 218, STR_02C0_SAVE_CUSTOM_NAMES, STR_02C2_SAVE_CUSTOMIZED_VEHICLE}, |
0 | 333 |
|
4344
5d0e40cd67b9
(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
|
334 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
335 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, |
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
193
diff
changeset
|
336 |
|
4344
5d0e40cd67b9
(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
|
337 |
{ WWT_FRAME, RESIZE_NONE, 14, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
338 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, |
4344
5d0e40cd67b9
(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
|
339 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, |
0 | 340 |
|
4344
5d0e40cd67b9
(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
|
341 |
{ WWT_FRAME, RESIZE_NONE, 14, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
342 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, |
0 | 343 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
344 |
{ WIDGETS_END}, |
0 | 345 |
}; |
346 |
||
347 |
static const WindowDesc _game_options_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
348 |
WDP_CENTER, WDP_CENTER, 370, 239, 370, 239, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5939
diff
changeset
|
349 |
WC_GAME_OPTIONS, WC_NONE, |
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2055
diff
changeset
|
350 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 351 |
_game_options_widgets, |
352 |
}; |
|
353 |
||
354 |
||
6573 | 355 |
void ShowGameOptions() |
0 | 356 |
{ |
357 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
10645 | 358 |
new GameOptionsWindow(&_game_options_desc); |
0 | 359 |
} |
360 |
||
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
361 |
struct GameSettingData { |
0 | 362 |
int16 min; |
363 |
int16 max; |
|
364 |
int16 step; |
|
365 |
StringID str; |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
366 |
}; |
0 | 367 |
|
368 |
static const GameSettingData _game_setting_info[] = { |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
369 |
{ 0, 7, 1, STR_NULL}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
370 |
{ 0, 3, 1, STR_6830_IMMEDIATE}, |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
371 |
{ 0, 3, 1, STR_NUM_VERY_LOW}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
372 |
{ 0, 4, 1, STR_NONE}, |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
373 |
{100, 500, 50, STR_NULL}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
374 |
{ 2, 4, 1, STR_NULL}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
375 |
{ 0, 2, 1, STR_6820_LOW}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
376 |
{ 0, 4, 1, STR_681B_VERY_SLOW}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
377 |
{ 0, 2, 1, STR_6820_LOW}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
378 |
{ 0, 2, 1, STR_6823_NONE}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
379 |
{ 0, 3, 1, STR_6826_X1_5}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
380 |
{ 0, 2, 1, STR_6820_LOW}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
381 |
{ 0, 3, 1, STR_682A_VERY_FLAT}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
382 |
{ 0, 3, 1, STR_VERY_LOW}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
383 |
{ 0, 1, 1, STR_682E_STEADY}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
384 |
{ 0, 1, 1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS}, |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
385 |
{ 0, 1, 1, STR_6836_OFF}, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
386 |
{ 0, 2, 1, STR_PERMISSIVE}, |
0 | 387 |
}; |
388 |
||
1385
324d3d06a930
(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
|
389 |
/* |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
390 |
* A: competitors |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
391 |
* B: start time in months / 3 |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
392 |
* C: town count (3 = high, 0 = very low) |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
393 |
* D: industry count (4 = high, 0 = none) |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
394 |
* E: inital loan / 1000 (in GBP) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
395 |
* F: interest rate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
396 |
* G: running costs (0 = low, 2 = high) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
397 |
* H: construction speed of competitors (0 = very slow, 4 = very fast) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
398 |
* I: intelligence (0-2) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
399 |
* J: breakdowns (0 = off, 2 = normal) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
400 |
* K: subsidy multiplier (0 = 1.5, 3 = 4.0) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
401 |
* L: construction cost (0-2) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
402 |
* M: terrain type (0 = very flat, 3 = mountainous) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
403 |
* N: amount of water (0 = very low, 3 = high) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
404 |
* O: economy (0 = steady, 1 = fluctuating) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
405 |
* P: Train reversing (0 = end of line + stations, 1 = end of line) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
406 |
* Q: disasters |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
407 |
* R: area restructuring (0 = permissive, 2 = hostile) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4488
diff
changeset
|
408 |
*/ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
409 |
static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* |
1385
324d3d06a930
(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
|
410 |
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
411 |
{2, 2, 2, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
412 |
{4, 1, 2, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
413 |
{7, 0, 3, 3, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard |
0 | 414 |
}; |
415 |
||
416 |
void SetDifficultyLevel(int mode, GameOptions *gm_opt) |
|
417 |
{ |
|
418 |
int i; |
|
419 |
assert(mode <= 3); |
|
420 |
||
421 |
gm_opt->diff_level = mode; |
|
422 |
if (mode != 3) { // not custom |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1477
diff
changeset
|
423 |
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
424 |
((GDType*)&gm_opt->diff)[i] = _default_game_diff[mode][i]; |
0 | 425 |
} |
426 |
} |
|
427 |
||
9545 | 428 |
/** |
429 |
* Checks the difficulty levels read from the configuration and |
|
430 |
* forces them to be correct when invalid. |
|
431 |
*/ |
|
432 |
void CheckDifficultyLevels() |
|
433 |
{ |
|
434 |
if (_opt_newgame.diff_level != 3) { |
|
435 |
SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame); |
|
436 |
} else { |
|
437 |
for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) { |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
438 |
GDType *diff = ((GDType*)&_opt_newgame.diff) + i; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
439 |
*diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max); |
9545 | 440 |
*diff -= *diff % _game_setting_info[i].step; |
441 |
} |
|
442 |
} |
|
443 |
} |
|
444 |
||
6573 | 445 |
extern void StartupEconomy(); |
46
c9bdf1d58df6
(svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents:
42
diff
changeset
|
446 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
447 |
/* Widget definition for the game difficulty settings window */ |
0 | 448 |
static const Widget _game_difficulty_widgets[] = { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
449 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // GDW_CLOSEBOX |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
450 |
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
451 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, // GDW_UPPER_BG |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
452 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_6801_EASY, STR_NULL}, // GDW_LVL_EASY |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
453 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_6802_MEDIUM, STR_NULL}, // GDW_LVL_MEDIUM |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
454 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_6803_HARD, STR_NULL}, // GDW_LVL_HARD |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
455 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_6804_CUSTOM, STR_NULL}, // GDW_LVL_CUSTOM |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
456 |
{ WWT_TEXTBTN, RESIZE_NONE, 6, 10, 357, 28, 39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL}, // GDW_HIGHSCORE |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
457 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 262, 0x0, STR_NULL}, // GDW_SETTING_BG |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
458 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 263, 278, 0x0, STR_NULL}, // GDW_LOWER_BG |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
459 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 105, 185, 265, 276, STR_OPTIONS_SAVE_CHANGES, STR_NULL}, // GDW_ACCEPT |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
460 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 3, 186, 266, 265, 276, STR_012E_CANCEL, STR_NULL}, // GDW_CANCEL |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
461 |
{ WIDGETS_END}, |
0 | 462 |
}; |
463 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
464 |
/* Window definition for the game difficulty settings window */ |
0 | 465 |
static const WindowDesc _game_difficulty_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
466 |
WDP_CENTER, WDP_CENTER, 370, 279, 370, 279, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5939
diff
changeset
|
467 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 468 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
469 |
_game_difficulty_widgets, |
|
10645 | 470 |
}; |
471 |
||
472 |
struct GameDifficultyWindow : public Window { |
|
473 |
private: |
|
474 |
bool clicked_increase; |
|
475 |
uint8 clicked_button; |
|
476 |
uint8 timeout; |
|
477 |
||
478 |
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */ |
|
479 |
GameOptions opt_mod_temp; |
|
480 |
||
481 |
enum { |
|
482 |
GAMEDIFF_WND_TOP_OFFSET = 45, |
|
483 |
GAMEDIFF_WND_ROWSIZE = 9, |
|
484 |
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) |
|
485 |
DIFF_INGAME_DISABLED_BUTTONS = 0x383E, |
|
486 |
NO_SETTINGS_BUTTON = 0xFF, |
|
487 |
}; |
|
488 |
||
489 |
/* Names of the game difficulty settings window */ |
|
490 |
enum GameDifficultyWidgets { |
|
491 |
GDW_CLOSEBOX = 0, |
|
492 |
GDW_CAPTION, |
|
493 |
GDW_UPPER_BG, |
|
494 |
GDW_LVL_EASY, |
|
495 |
GDW_LVL_MEDIUM, |
|
496 |
GDW_LVL_HARD, |
|
497 |
GDW_LVL_CUSTOM, |
|
498 |
GDW_HIGHSCORE, |
|
499 |
GDW_SETTING_BG, |
|
500 |
GDW_LOWER_BG, |
|
501 |
GDW_ACCEPT, |
|
502 |
GDW_CANCEL, |
|
503 |
}; |
|
504 |
||
505 |
public: |
|
506 |
GameDifficultyWindow() : Window(&_game_difficulty_desc) |
|
507 |
{ |
|
508 |
/* Copy current settings (ingame or in intro) to temporary holding place |
|
509 |
* change that when setting stuff, copy back on clicking 'OK' */ |
|
510 |
this->opt_mod_temp = *_opt_ptr; |
|
511 |
this->clicked_increase = false; |
|
512 |
this->clicked_button = NO_SETTINGS_BUTTON; |
|
513 |
this->timeout = 0; |
|
514 |
/* Hide the closebox to make sure that the user aborts or confirms his changes */ |
|
515 |
this->HideWidget(GDW_CLOSEBOX); |
|
516 |
this->widget[GDW_CAPTION].left = 0; |
|
517 |
/* Setup disabled buttons when creating window |
|
518 |
* disable all other difficulty buttons during gameplay except for 'custom' */ |
|
519 |
this->SetWidgetsDisabledState(_game_mode == GM_NORMAL, |
|
520 |
GDW_LVL_EASY, |
|
521 |
GDW_LVL_MEDIUM, |
|
522 |
GDW_LVL_HARD, |
|
523 |
GDW_LVL_CUSTOM, |
|
524 |
WIDGET_LIST_END); |
|
525 |
this->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer |
|
526 |
this->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client) |
|
527 |
this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level); |
|
528 |
this->FindWindowPlacementAndResize(&_game_difficulty_desc); |
|
529 |
} |
|
530 |
||
531 |
virtual void OnPaint() |
|
532 |
{ |
|
533 |
this->DrawWidgets(); |
|
534 |
||
535 |
/* XXX - Disabled buttons in normal gameplay or during muliplayer as non server. |
|
536 |
* Bitshifted for each button to see if that bit is set. If it is set, the |
|
537 |
* button is disabled */ |
|
538 |
uint32 disabled = 0; |
|
539 |
if (_networking && !_network_server) { |
|
540 |
disabled = MAX_UVALUE(uint32); // Disable all |
|
541 |
} else if (_game_mode == GM_NORMAL) { |
|
542 |
disabled = DIFF_INGAME_DISABLED_BUTTONS; |
|
543 |
} |
|
544 |
||
545 |
int value; |
|
546 |
int y = GAMEDIFF_WND_TOP_OFFSET; |
|
547 |
for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) { |
|
548 |
const GameSettingData *gsd = &_game_setting_info[i]; |
|
549 |
value = ((GDType*)&this->opt_mod_temp.diff)[i]; |
|
550 |
||
551 |
DrawArrowButtons(5, y, 3, |
|
552 |
(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0, |
|
553 |
!(HasBit(disabled, i) || gsd->min == value), |
|
554 |
!(HasBit(disabled, i) || gsd->max == value)); |
|
555 |
||
556 |
value += _game_setting_info[i].str; |
|
557 |
if (i == 4) value *= 1000; // XXX - handle currency option |
|
558 |
SetDParam(0, value); |
|
559 |
DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING); |
|
560 |
||
561 |
y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit |
|
562 |
} |
|
563 |
} |
|
564 |
||
565 |
virtual void OnClick(Point pt, int widget) |
|
566 |
{ |
|
567 |
switch (widget) { |
|
568 |
case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */ |
|
569 |
/* Don't allow clients to make any changes */ |
|
570 |
if (_networking && !_network_server) return; |
|
571 |
||
572 |
const int x = pt.x - 5; |
|
573 |
if (!IsInsideMM(x, 0, 21)) return; // Button area |
|
574 |
||
575 |
const int y = pt.y - GAMEDIFF_WND_TOP_OFFSET; |
|
576 |
if (y < 0) return; |
|
577 |
||
578 |
/* Get button from Y coord. */ |
|
579 |
const uint8 btn = y / (GAMEDIFF_WND_ROWSIZE + 2); |
|
580 |
if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) return; |
|
581 |
||
582 |
/* Clicked disabled button? */ |
|
583 |
if (_game_mode == GM_NORMAL && HasBit((int)DIFF_INGAME_DISABLED_BUTTONS, btn)) return; |
|
584 |
||
585 |
this->timeout = 5; |
|
586 |
||
587 |
int16 val = ((GDType*)&this->opt_mod_temp.diff)[btn]; |
|
588 |
||
589 |
const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting |
|
590 |
if (x >= 10) { |
|
591 |
/* Increase button clicked */ |
|
592 |
val = min(val + info->step, info->max); |
|
593 |
this->clicked_increase = true; |
|
594 |
} else { |
|
595 |
/* Decrease button clicked */ |
|
596 |
val -= info->step; |
|
597 |
val = max(val, info->min); |
|
598 |
this->clicked_increase = false; |
|
599 |
} |
|
600 |
this->clicked_button = btn; |
|
601 |
||
602 |
/* save value in temporary variable */ |
|
603 |
((GDType*)&this->opt_mod_temp.diff)[btn] = val; |
|
604 |
this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level); |
|
605 |
SetDifficultyLevel(3, &this->opt_mod_temp); // set difficulty level to custom |
|
606 |
this->LowerWidget(GDW_LVL_CUSTOM); |
|
607 |
this->SetDirty(); |
|
608 |
} break; |
|
609 |
||
610 |
case GDW_LVL_EASY: |
|
611 |
case GDW_LVL_MEDIUM: |
|
612 |
case GDW_LVL_HARD: |
|
613 |
case GDW_LVL_CUSTOM: |
|
614 |
/* temporarily change difficulty level */ |
|
615 |
this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level); |
|
616 |
SetDifficultyLevel(widget - GDW_LVL_EASY, &this->opt_mod_temp); |
|
617 |
this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level); |
|
618 |
this->SetDirty(); |
|
619 |
break; |
|
620 |
||
621 |
case GDW_HIGHSCORE: // Highscore Table |
|
622 |
ShowHighscoreTable(this->opt_mod_temp.diff_level, -1); |
|
623 |
break; |
|
624 |
||
625 |
case GDW_ACCEPT: { // Save button - save changes |
|
626 |
GDType btn, val; |
|
627 |
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) { |
|
628 |
val = ((GDType*)&this->opt_mod_temp.diff)[btn]; |
|
629 |
/* if setting has changed, change it */ |
|
630 |
if (val != ((GDType*)&_opt_ptr->diff)[btn]) |
|
631 |
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
632 |
} |
|
633 |
DoCommandP(0, UINT_MAX, this->opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
634 |
delete this; |
|
635 |
/* If we are in the editor, we should reload the economy. |
|
636 |
* This way when you load a game, the max loan and interest rate |
|
637 |
* are loaded correctly. */ |
|
638 |
if (_game_mode == GM_EDITOR) StartupEconomy(); |
|
639 |
break; |
|
640 |
} |
|
641 |
||
642 |
case GDW_CANCEL: // Cancel button - close window, abandon changes |
|
643 |
delete this; |
|
644 |
break; |
|
645 |
} |
|
646 |
} |
|
647 |
||
648 |
virtual void OnTick() |
|
649 |
{ |
|
650 |
if (this->timeout != 0) { |
|
651 |
this->timeout--; |
|
652 |
if (this->timeout == 0) this->clicked_button = NO_SETTINGS_BUTTON; |
|
653 |
this->SetDirty(); |
|
654 |
} |
|
655 |
} |
|
0 | 656 |
}; |
657 |
||
6573 | 658 |
void ShowGameDifficulty() |
0 | 659 |
{ |
660 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
10645 | 661 |
new GameDifficultyWindow(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
662 |
} |
0 | 663 |
|
3247
4e70e64adbb8
(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 |
static const char *_patches_ui[] = { |
4e70e64adbb8
(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 |
"vehicle_speed", |
4e70e64adbb8
(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 |
"status_long_date", |
4e70e64adbb8
(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 |
"show_finances", |
4e70e64adbb8
(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 |
"autoscroll", |
4e70e64adbb8
(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
|
669 |
"reverse_scroll", |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
670 |
"smooth_scroll", |
3247
4e70e64adbb8
(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
|
671 |
"errmsg_duration", |
4e70e64adbb8
(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
|
672 |
"toolbar_pos", |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4727
diff
changeset
|
673 |
"measure_tooltip", |
3247
4e70e64adbb8
(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
|
674 |
"window_snap_radius", |
4e70e64adbb8
(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
|
675 |
"population_in_label", |
4e70e64adbb8
(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
|
676 |
"link_terraform_toolbar", |
4616
baa9d4436b9e
(svn r6474) - Add a patch option to control display of liveries, allowing none, your
peter1138
parents:
4552
diff
changeset
|
677 |
"liveries", |
5107
8791beb0ae51
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
678 |
"prefer_teamchat", |
6615
96d30d65ed35
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents:
6585
diff
changeset
|
679 |
/* While the horizontal scrollwheel scrolling is written as general code, only |
96d30d65ed35
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents:
6585
diff
changeset
|
680 |
* the cocoa (OSX) driver generates input for it. |
6622
2ce7ffa9db00
(svn r9126) -Feature: "Function of scrollwheel" can now be set to off as well
bjarni
parents:
6619
diff
changeset
|
681 |
* Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */ |
6615
96d30d65ed35
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents:
6585
diff
changeset
|
682 |
"scrollwheel_scrolling", |
96d30d65ed35
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents:
6585
diff
changeset
|
683 |
"scrollwheel_multiplier", |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
684 |
#ifdef __APPLE__ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
685 |
/* We might need to emulate a right mouse button on mac */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
686 |
"right_mouse_btn_emulation", |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
687 |
#endif |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
688 |
"pause_on_newgame", |
9624 | 689 |
"advanced_vehicle_list", |
9629 | 690 |
"loading_indicators", |
691 |
"timetable_in_ticks", |
|
692 |
"default_rail_type", |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
693 |
"always_build_infrastructure", |
21 | 694 |
}; |
695 |
||
3247
4e70e64adbb8
(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 |
static const char *_patches_construction[] = { |
4e70e64adbb8
(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 |
"build_on_slopes", |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
698 |
"autoslope", |
3247
4e70e64adbb8
(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 |
"extra_dynamite", |
4e70e64adbb8
(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 |
"longbridges", |
4e70e64adbb8
(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 |
"signal_side", |
4e70e64adbb8
(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
|
702 |
"always_small_airport", |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
703 |
"enable_signal_gui", |
3247
4e70e64adbb8
(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
|
704 |
"drag_signals_density", |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
705 |
"oil_refinery_limit", |
5939
77530457a36b
(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents:
5919
diff
changeset
|
706 |
"semaphore_build_before", |
3247
4e70e64adbb8
(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
|
707 |
}; |
4e70e64adbb8
(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
|
708 |
|
4e70e64adbb8
(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
|
709 |
static const char *_patches_stations[] = { |
4e70e64adbb8
(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
|
710 |
"join_stations", |
4e70e64adbb8
(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
|
711 |
"improved_load", |
4e70e64adbb8
(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
|
712 |
"selectgoods", |
4e70e64adbb8
(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
|
713 |
"new_nonstop", |
4e70e64adbb8
(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
|
714 |
"nonuniform_stations", |
4e70e64adbb8
(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 |
"station_spread", |
4e70e64adbb8
(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 |
"serviceathelipad", |
4e70e64adbb8
(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
|
717 |
"modified_catchment", |
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5163
diff
changeset
|
718 |
"gradual_loading", |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
719 |
"road_stop_on_town_road", |
9624 | 720 |
"adjacent_stations", |
3247
4e70e64adbb8
(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
|
721 |
}; |
4e70e64adbb8
(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
|
722 |
|
4e70e64adbb8
(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
|
723 |
static const char *_patches_economy[] = { |
4e70e64adbb8
(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
|
724 |
"inflation", |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
725 |
"raw_industry_construction", |
3247
4e70e64adbb8
(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
|
726 |
"multiple_industry_per_town", |
4e70e64adbb8
(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
|
727 |
"same_industry_close", |
4e70e64adbb8
(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
|
728 |
"bribe", |
9704 | 729 |
"exclusive_rights", |
730 |
"give_money", |
|
4285
72b3f7d6c891
(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
|
731 |
"colored_news_year", |
72b3f7d6c891
(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
|
732 |
"ending_year", |
3247
4e70e64adbb8
(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
|
733 |
"smooth_economy", |
4e70e64adbb8
(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
|
734 |
"allow_shares", |
9704 | 735 |
"town_layout", |
736 |
"mod_road_rebuild", |
|
9599 | 737 |
"town_growth_rate", |
738 |
"larger_towns", |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
739 |
"initial_city_size", |
3247
4e70e64adbb8
(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
|
740 |
}; |
4e70e64adbb8
(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
|
741 |
|
4e70e64adbb8
(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
|
742 |
static const char *_patches_ai[] = { |
4e70e64adbb8
(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
|
743 |
"ai_in_multiplayer", |
4e70e64adbb8
(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
|
744 |
"ai_disable_veh_train", |
4e70e64adbb8
(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
|
745 |
"ai_disable_veh_roadveh", |
4e70e64adbb8
(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
|
746 |
"ai_disable_veh_aircraft", |
4e70e64adbb8
(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
|
747 |
"ai_disable_veh_ship", |
4e70e64adbb8
(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
|
748 |
}; |
4e70e64adbb8
(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
|
749 |
|
4e70e64adbb8
(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
|
750 |
static const char *_patches_vehicles[] = { |
4e70e64adbb8
(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
|
751 |
"realistic_acceleration", |
4e70e64adbb8
(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
|
752 |
"forbid_90_deg", |
4e70e64adbb8
(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
|
753 |
"mammoth_trains", |
4e70e64adbb8
(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
|
754 |
"gotodepot", |
4e70e64adbb8
(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
|
755 |
"roadveh_queue", |
9732 | 756 |
"pathfinder_for_trains", |
757 |
"pathfinder_for_roadvehs", |
|
758 |
"pathfinder_for_ships", |
|
3247
4e70e64adbb8
(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
|
759 |
"train_income_warn", |
4e70e64adbb8
(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
|
760 |
"order_review_system", |
4e70e64adbb8
(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
|
761 |
"never_expire_vehicles", |
4870
0ee22ed51ada
(svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents:
4834
diff
changeset
|
762 |
"lost_train_warn", |
3247
4e70e64adbb8
(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
|
763 |
"autorenew", |
4e70e64adbb8
(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
|
764 |
"autorenew_months", |
4e70e64adbb8
(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
|
765 |
"autorenew_money", |
4e70e64adbb8
(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
|
766 |
"max_trains", |
4e70e64adbb8
(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
|
767 |
"max_roadveh", |
4e70e64adbb8
(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
|
768 |
"max_aircraft", |
4e70e64adbb8
(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
|
769 |
"max_ships", |
4e70e64adbb8
(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
|
770 |
"servint_ispercent", |
4e70e64adbb8
(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
|
771 |
"servint_trains", |
4e70e64adbb8
(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
|
772 |
"servint_roadveh", |
4e70e64adbb8
(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
|
773 |
"servint_ships", |
4e70e64adbb8
(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
|
774 |
"servint_aircraft", |
4e70e64adbb8
(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
|
775 |
"no_servicing_if_no_breakdowns", |
4e70e64adbb8
(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
|
776 |
"wagon_speed_limits", |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5113
diff
changeset
|
777 |
"disable_elrails", |
5163
83acad83bbdd
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents:
5141
diff
changeset
|
778 |
"freight_trains", |
9800 | 779 |
"plane_speed", |
9629 | 780 |
"timetabling", |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10249
diff
changeset
|
781 |
"dynamic_engines", |
3247
4e70e64adbb8
(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
|
782 |
}; |
4e70e64adbb8
(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
|
783 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
784 |
struct PatchEntry { |
3247
4e70e64adbb8
(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
|
785 |
const SettingDesc *setting; |
4e70e64adbb8
(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
|
786 |
uint index; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
787 |
}; |
3247
4e70e64adbb8
(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
|
788 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
789 |
struct PatchPage { |
3247
4e70e64adbb8
(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
|
790 |
const char **names; |
4e70e64adbb8
(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
|
791 |
PatchEntry *entries; |
3118
99926945ccb1
(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 |
byte num; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
793 |
}; |
0 | 794 |
|
3247
4e70e64adbb8
(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
|
795 |
/* PatchPage holds the categories, the number of elements in each category |
4e70e64adbb8
(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
|
796 |
* and (in NULL) a dynamic array of settings based on the string-representations |
4e70e64adbb8
(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
|
797 |
* of the settings. This way there is no worry about indeces, and such */ |
4e70e64adbb8
(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
|
798 |
static PatchPage _patches_page[] = { |
4e70e64adbb8
(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
|
799 |
{_patches_ui, NULL, lengthof(_patches_ui)}, |
4e70e64adbb8
(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
|
800 |
{_patches_construction, NULL, lengthof(_patches_construction)}, |
4e70e64adbb8
(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
|
801 |
{_patches_vehicles, NULL, lengthof(_patches_vehicles)}, |
4e70e64adbb8
(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
|
802 |
{_patches_stations, NULL, lengthof(_patches_stations)}, |
4e70e64adbb8
(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
|
803 |
{_patches_economy, NULL, lengthof(_patches_economy)}, |
4e70e64adbb8
(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
|
804 |
{_patches_ai, NULL, lengthof(_patches_ai)}, |
0 | 805 |
}; |
806 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
807 |
enum PatchesSelectionWidgets { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
808 |
PATCHSEL_OPTIONSPANEL = 3, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
809 |
PATCHSEL_INTERFACE, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
810 |
PATCHSEL_CONSTRUCTION, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
811 |
PATCHSEL_VEHICLES, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
812 |
PATCHSEL_STATIONS, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
813 |
PATCHSEL_ECONOMY, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
814 |
PATCHSEL_COMPETITORS |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
815 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
816 |
|
10645 | 817 |
struct PatchesSelectionWindow : Window { |
3118
99926945ccb1
(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
|
818 |
static Patches *patches_ptr; |
10645 | 819 |
static int patches_max; |
3118
99926945ccb1
(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 |
|
10645 | 821 |
int page; |
822 |
int entry; |
|
823 |
int click; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
824 |
|
10645 | 825 |
PatchesSelectionWindow(const WindowDesc *desc) : Window(desc) |
826 |
{ |
|
827 |
static bool first_time = true; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
828 |
|
10645 | 829 |
patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
830 |
|
10645 | 831 |
/* Build up the dynamic settings-array only once per OpenTTD session */ |
832 |
if (first_time) { |
|
833 |
PatchPage *page; |
|
834 |
for (page = &_patches_page[0]; page != endof(_patches_page); page++) { |
|
835 |
uint i; |
|
836 |
||
837 |
if (patches_max < page->num) patches_max = page->num; |
|
838 |
||
839 |
page->entries = MallocT<PatchEntry>(page->num); |
|
840 |
for (i = 0; i != page->num; i++) { |
|
841 |
uint index; |
|
842 |
const SettingDesc *sd = GetPatchFromName(page->names[i], &index); |
|
843 |
assert(sd != NULL); |
|
844 |
||
845 |
page->entries[i].setting = sd; |
|
846 |
page->entries[i].index = index; |
|
847 |
} |
|
848 |
} |
|
849 |
first_time = false; |
|
850 |
} |
|
851 |
||
852 |
/* Resize the window to fit the largest patch tab */ |
|
853 |
ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11); |
|
854 |
||
855 |
/* Recentre the window for the new size */ |
|
856 |
this->top = this->top - (patches_max * 11) / 2; |
|
857 |
||
858 |
this->LowerWidget(4); |
|
859 |
||
860 |
this->FindWindowPlacementAndResize(desc); |
|
861 |
} |
|
862 |
||
863 |
virtual void OnPaint() |
|
864 |
{ |
|
865 |
int x, y; |
|
866 |
const PatchPage *page = &_patches_page[this->page]; |
|
867 |
uint i; |
|
868 |
||
869 |
/* Set up selected category */ |
|
870 |
this->DrawWidgets(); |
|
871 |
||
872 |
x = 5; |
|
873 |
y = 47; |
|
874 |
for (i = 0; i != page->num; i++) { |
|
875 |
const SettingDesc *sd = page->entries[i].setting; |
|
876 |
const SettingDescBase *sdb = &sd->desc; |
|
877 |
const void *var = GetVariableAddress(patches_ptr, &sd->save); |
|
878 |
bool editable = true; |
|
879 |
bool disabled = false; |
|
880 |
||
881 |
// We do not allow changes of some items when we are a client in a networkgame |
|
882 |
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false; |
|
883 |
if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false; |
|
884 |
if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false; |
|
885 |
||
886 |
if (sdb->cmd == SDT_BOOLX) { |
|
887 |
static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}}; |
|
888 |
/* Draw checkbox for boolean-value either on/off */ |
|
889 |
bool on = (*(bool*)var); |
|
890 |
||
891 |
DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE); |
|
892 |
SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
|
893 |
} else { |
|
894 |
int32 value; |
|
895 |
||
896 |
value = (int32)ReadValue(var, sd->save.conv); |
|
897 |
||
898 |
/* Draw [<][>] boxes for settings of an integer-type */ |
|
899 |
DrawArrowButtons(x, y, 3, this->click - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); |
|
900 |
||
901 |
disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); |
|
902 |
if (disabled) { |
|
903 |
SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
|
904 |
} else { |
|
905 |
if (sdb->flags & SGF_CURRENCY) { |
|
906 |
SetDParam(0, STR_CONFIG_PATCHES_CURRENCY); |
|
907 |
} else if (sdb->flags & SGF_MULTISTRING) { |
|
908 |
SetDParam(0, sdb->str + value + 1); |
|
0 | 909 |
} else { |
10645 | 910 |
SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024); |
911 |
} |
|
912 |
SetDParam(1, value); |
|
913 |
} |
|
914 |
} |
|
915 |
DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING); |
|
916 |
y += 11; |
|
917 |
} |
|
918 |
} |
|
919 |
||
920 |
virtual void OnClick(Point pt, int widget) |
|
921 |
{ |
|
922 |
switch (widget) { |
|
923 |
case PATCHSEL_OPTIONSPANEL: { |
|
924 |
const PatchPage *page = &_patches_page[this->page]; |
|
925 |
const SettingDesc *sd; |
|
926 |
void *var; |
|
927 |
int32 value; |
|
928 |
int x, y; |
|
929 |
byte btn; |
|
930 |
||
931 |
y = pt.y - 46 - 1; |
|
932 |
if (y < 0) return; |
|
933 |
||
934 |
x = pt.x - 5; |
|
935 |
if (x < 0) return; |
|
936 |
||
937 |
btn = y / 11; |
|
938 |
if (y % 11 > 9) return; |
|
939 |
if (btn >= page->num) return; |
|
940 |
||
941 |
sd = page->entries[btn].setting; |
|
942 |
||
943 |
/* return if action is only active in network, or only settable by server */ |
|
944 |
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return; |
|
945 |
if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return; |
|
946 |
if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return; |
|
947 |
||
948 |
var = GetVariableAddress(patches_ptr, &sd->save); |
|
949 |
value = (int32)ReadValue(var, sd->save.conv); |
|
950 |
||
951 |
/* clicked on the icon on the left side. Either scroller or bool on/off */ |
|
952 |
if (x < 21) { |
|
953 |
const SettingDescBase *sdb = &sd->desc; |
|
954 |
int32 oldvalue = value; |
|
955 |
||
956 |
switch (sdb->cmd) { |
|
957 |
case SDT_BOOLX: value ^= 1; break; |
|
958 |
case SDT_NUMX: { |
|
959 |
/* Add a dynamic step-size to the scroller. In a maximum of |
|
960 |
* 50-steps you should be able to get from min to max, |
|
961 |
* unless specified otherwise in the 'interval' variable |
|
962 |
* of the current patch. */ |
|
963 |
uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval; |
|
964 |
if (step == 0) step = 1; |
|
965 |
||
966 |
// don't allow too fast scrolling |
|
967 |
if ((this->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) { |
|
968 |
_left_button_clicked = false; |
|
969 |
return; |
|
970 |
} |
|
971 |
||
972 |
/* Increase or decrease the value and clamp it to extremes */ |
|
973 |
if (x >= 10) { |
|
974 |
value += step; |
|
975 |
if (value > sdb->max) value = sdb->max; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
976 |
} else { |
10645 | 977 |
value -= step; |
978 |
if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
979 |
} |
10645 | 980 |
|
981 |
/* Set up scroller timeout for numeric values */ |
|
982 |
if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { |
|
983 |
this->click = btn * 2 + 1 + ((x >= 10) ? 1 : 0); |
|
984 |
this->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
985 |
_left_button_clicked = false; |
|
986 |
} |
|
987 |
} break; |
|
988 |
default: NOT_REACHED(); |
|
989 |
} |
|
990 |
||
991 |
if (value != oldvalue) { |
|
992 |
SetPatchValue(page->entries[btn].index, patches_ptr, value); |
|
993 |
this->SetDirty(); |
|
994 |
} |
|
995 |
} else { |
|
996 |
/* only open editbox for types that its sensible for */ |
|
997 |
if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { |
|
998 |
/* Show the correct currency-translated value */ |
|
999 |
if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; |
|
1000 |
||
1001 |
this->entry = btn; |
|
1002 |
SetDParam(0, value); |
|
1003 |
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, this, CS_NUMERAL); |
|
0 | 1004 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1005 |
} |
10645 | 1006 |
} break; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1007 |
|
10645 | 1008 |
case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES: |
1009 |
case PATCHSEL_STATIONS: case PATCHSEL_ECONOMY: case PATCHSEL_COMPETITORS: |
|
1010 |
this->RaiseWidget(this->page + PATCHSEL_INTERFACE); |
|
1011 |
this->page = widget - PATCHSEL_INTERFACE; |
|
1012 |
this->LowerWidget(this->page + PATCHSEL_INTERFACE); |
|
1013 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1014 |
this->SetDirty(); |
|
1015 |
break; |
|
1016 |
} |
|
1017 |
} |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1018 |
|
10645 | 1019 |
virtual void OnTimeout() |
1020 |
{ |
|
1021 |
this->click = 0; |
|
1022 |
this->SetDirty(); |
|
1023 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1024 |
|
10645 | 1025 |
virtual void OnQueryTextFinished(char *str) |
1026 |
{ |
|
1027 |
if (!StrEmpty(str)) { |
|
1028 |
const PatchEntry *pe = &_patches_page[this->page].entries[this->entry]; |
|
1029 |
const SettingDesc *sd = pe->setting; |
|
1030 |
int32 value = atoi(str); |
|
3118
99926945ccb1
(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
|
1031 |
|
10645 | 1032 |
/* Save the correct currency-translated value */ |
1033 |
if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; |
|
0 | 1034 |
|
10645 | 1035 |
SetPatchValue(pe->index, patches_ptr, value); |
1036 |
this->SetDirty(); |
|
1037 |
} |
|
1038 |
} |
|
1039 |
}; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1040 |
|
10645 | 1041 |
Patches *PatchesSelectionWindow::patches_ptr = NULL; |
1042 |
int PatchesSelectionWindow::patches_max = 0; |
|
0 | 1043 |
|
1044 |
static const Widget _patches_selection_widgets[] = { |
|
4344
5d0e40cd67b9
(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
|
1045 |
{ WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(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
|
1046 |
{ WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(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
|
1047 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, |
9732 | 1048 |
{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 50, 0x0, STR_NULL}, |
0 | 1049 |
|
4344
5d0e40cd67b9
(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
|
1050 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, |
5d0e40cd67b9
(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
|
1051 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, |
5d0e40cd67b9
(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
|
1052 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, |
5d0e40cd67b9
(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
|
1053 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, |
5d0e40cd67b9
(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
|
1054 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, |
5d0e40cd67b9
(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
|
1055 |
{ 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
|
1056 |
{ WIDGETS_END}, |
0 | 1057 |
}; |
1058 |
||
1059 |
static const WindowDesc _patches_selection_desc = { |
|
9732 | 1060 |
WDP_CENTER, WDP_CENTER, 370, 51, 370, 51, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5939
diff
changeset
|
1061 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 1062 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1063 |
_patches_selection_widgets, |
|
1064 |
}; |
|
1065 |
||
6573 | 1066 |
void ShowPatchesSelection() |
0 | 1067 |
{ |
1068 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
10645 | 1069 |
new PatchesSelectionWindow(&_patches_selection_desc); |
0 | 1070 |
} |
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1071 |
|
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
430
diff
changeset
|
1072 |
|
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1073 |
/** |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1074 |
* Draw [<][>] boxes. |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1075 |
* @param x the x position to draw |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1076 |
* @param y the y position to draw |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1077 |
* @param ctab the color of the buttons |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1078 |
* @param state 0 = none clicked, 1 = first clicked, 2 = second clicked |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1079 |
* @param clickable_left is the left button clickable? |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1080 |
* @param clickable_right is the right button clickable? |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1081 |
*/ |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1082 |
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right) |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1083 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5860
diff
changeset
|
1084 |
int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2]; |
3107
a6406bbecd3d
(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
|
1085 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1086 |
DrawFrameRect(x, y + 1, x + 9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1087 |
DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1088 |
DrawStringCentered(x + 5, y + 1, STR_6819, TC_FROMSTRING); // [<] |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1089 |
DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>] |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1090 |
|
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1091 |
/* Grey out the buttons that aren't clickable */ |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1092 |
if (!clickable_left) |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1093 |
GfxFillRect(x + 1, y + 1, x + 1 + 8, y + 8, color); |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1094 |
if (!clickable_right) |
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4196
diff
changeset
|
1095 |
GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1096 |
} |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1097 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1098 |
/** These are not, strickly speaking, widget enums, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1099 |
* since they have been changed as line coordinates. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1100 |
* So, rather, they are more like order of appearance */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1101 |
enum CustomCurrenciesWidgets { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1102 |
CUSTCURR_EXCHANGERATE = 0, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1103 |
CUSTCURR_SEPARATOR, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1104 |
CUSTCURR_PREFIX, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1105 |
CUSTCURR_SUFFIX, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1106 |
CUSTCURR_TO_EURO, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1107 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1108 |
|
10645 | 1109 |
struct CustomCurrencyWindow : Window { |
1110 |
char separator[2]; |
|
1111 |
int click; |
|
1112 |
int query_widget; |
|
4488
6eb5f6192c3a
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1113 |
|
10645 | 1114 |
CustomCurrencyWindow(const WindowDesc *desc) : Window(desc) |
1115 |
{ |
|
1116 |
this->separator[0] = _custom_currency.separator; |
|
1117 |
this->separator[1] = '\0'; |
|
1118 |
this->FindWindowPlacementAndResize(desc); |
|
1119 |
} |
|
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
788
diff
changeset
|
1120 |
|
10645 | 1121 |
virtual void OnPaint() |
1122 |
{ |
|
1123 |
int x; |
|
1124 |
int y = 20; |
|
1125 |
this->DrawWidgets(); |
|
2639 | 1126 |
|
10645 | 1127 |
/* exchange rate */ |
1128 |
DrawArrowButtons(10, y, 3, GB(this->click, 0, 2), true, true); |
|
1129 |
SetDParam(0, 1); |
|
1130 |
SetDParam(1, 1); |
|
1131 |
DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING); |
|
1132 |
y += 12; |
|
2639 | 1133 |
|
10645 | 1134 |
/* separator */ |
1135 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(this->click, 2, 2) ? FR_LOWERED : FR_NONE); |
|
1136 |
x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING); |
|
1137 |
DoDrawString(this->separator, x + 4, y + 1, TC_ORANGE); |
|
1138 |
y += 12; |
|
1139 |
||
1140 |
/* prefix */ |
|
1141 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(this->click, 4, 2) ? FR_LOWERED : FR_NONE); |
|
1142 |
x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING); |
|
1143 |
DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE); |
|
1144 |
y += 12; |
|
1145 |
||
1146 |
/* suffix */ |
|
1147 |
DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(this->click, 6, 2) ? FR_LOWERED : FR_NONE); |
|
1148 |
x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING); |
|
1149 |
DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE); |
|
1150 |
y += 12; |
|
1151 |
||
1152 |
/* switch to euro */ |
|
1153 |
DrawArrowButtons(10, y, 3, GB(this->click, 8, 2), true, true); |
|
1154 |
SetDParam(0, _custom_currency.to_euro); |
|
1155 |
DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING); |
|
1156 |
y += 12; |
|
1157 |
||
1158 |
/* Preview */ |
|
1159 |
y += 12; |
|
1160 |
SetDParam(0, 10000); |
|
1161 |
DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING); |
|
1162 |
} |
|
1163 |
||
1164 |
virtual void OnClick(Point pt, int widget) |
|
1165 |
{ |
|
1166 |
int line = (pt.y - 20) / 12; |
|
1167 |
int len = 0; |
|
1168 |
int x = pt.x; |
|
1169 |
StringID str = 0; |
|
1170 |
CharSetFilter afilter = CS_ALPHANUMERAL; |
|
1171 |
||
1172 |
switch (line) { |
|
1173 |
case CUSTCURR_EXCHANGERATE: |
|
1174 |
if (IsInsideMM(x, 10, 30)) { // clicked buttons |
|
1175 |
if (x < 20) { |
|
1176 |
if (_custom_currency.rate > 1) _custom_currency.rate--; |
|
1177 |
this->click = 1 << (line * 2 + 0); |
|
1178 |
} else { |
|
1179 |
if (_custom_currency.rate < 5000) _custom_currency.rate++; |
|
1180 |
this->click = 1 << (line * 2 + 1); |
|
4488
6eb5f6192c3a
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1181 |
} |
10645 | 1182 |
} else { // enter text |
1183 |
SetDParam(0, _custom_currency.rate); |
|
1184 |
str = STR_CONFIG_PATCHES_INT32; |
|
1185 |
len = 4; |
|
1186 |
afilter = CS_NUMERAL; |
|
1187 |
} |
|
1188 |
break; |
|
4488
6eb5f6192c3a
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1189 |
|
10645 | 1190 |
case CUSTCURR_SEPARATOR: |
1191 |
if (IsInsideMM(x, 10, 30)) { // clicked button |
|
1192 |
this->click = 1 << (line * 2 + 1); |
|
1193 |
} |
|
1194 |
str = BindCString(this->separator); |
|
1195 |
len = 1; |
|
1196 |
break; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1197 |
|
10645 | 1198 |
case CUSTCURR_PREFIX: |
1199 |
if (IsInsideMM(x, 10, 30)) { // clicked button |
|
1200 |
this->click = 1 << (line * 2 + 1); |
|
1201 |
} |
|
1202 |
str = BindCString(_custom_currency.prefix); |
|
1203 |
len = 12; |
|
1204 |
break; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1205 |
|
10645 | 1206 |
case CUSTCURR_SUFFIX: |
1207 |
if (IsInsideMM(x, 10, 30)) { // clicked button |
|
1208 |
this->click = 1 << (line * 2 + 1); |
|
1209 |
} |
|
1210 |
str = BindCString(_custom_currency.suffix); |
|
1211 |
len = 12; |
|
1212 |
break; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1213 |
|
10645 | 1214 |
case CUSTCURR_TO_EURO: |
1215 |
if (IsInsideMM(x, 10, 30)) { // clicked buttons |
|
1216 |
if (x < 20) { |
|
1217 |
_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? |
|
1218 |
CF_NOEURO : _custom_currency.to_euro - 1; |
|
1219 |
this->click = 1 << (line * 2 + 0); |
|
1220 |
} else { |
|
1221 |
_custom_currency.to_euro = |
|
1222 |
Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); |
|
1223 |
this->click = 1 << (line * 2 + 1); |
|
1224 |
} |
|
1225 |
} else { // enter text |
|
1226 |
SetDParam(0, _custom_currency.to_euro); |
|
1227 |
str = STR_CONFIG_PATCHES_INT32; |
|
1228 |
len = 4; |
|
1229 |
afilter = CS_NUMERAL; |
|
4488
6eb5f6192c3a
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1230 |
} |
10645 | 1231 |
break; |
1232 |
} |
|
1233 |
||
1234 |
if (len != 0) { |
|
1235 |
this->query_widget = line; |
|
1236 |
ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter); |
|
1237 |
} |
|
1238 |
||
1239 |
this->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
1240 |
this->SetDirty(); |
|
1241 |
} |
|
1242 |
||
1243 |
virtual void OnQueryTextFinished(char *str) |
|
1244 |
{ |
|
1245 |
if (str == NULL) return; |
|
1246 |
||
1247 |
switch (this->query_widget) { |
|
1248 |
case CUSTCURR_EXCHANGERATE: |
|
1249 |
_custom_currency.rate = Clamp(atoi(str), 1, 5000); |
|
1250 |
break; |
|
1251 |
||
1252 |
case CUSTCURR_SEPARATOR: /* Thousands seperator */ |
|
1253 |
_custom_currency.separator = StrEmpty(str) ? ' ' : str[0]; |
|
1254 |
ttd_strlcpy(this->separator, str, lengthof(this->separator)); |
|
1255 |
break; |
|
1256 |
||
1257 |
case CUSTCURR_PREFIX: |
|
1258 |
ttd_strlcpy(_custom_currency.prefix, str, lengthof(_custom_currency.prefix)); |
|
1259 |
break; |
|
1260 |
||
1261 |
case CUSTCURR_SUFFIX: |
|
1262 |
ttd_strlcpy(_custom_currency.suffix, str, lengthof(_custom_currency.suffix)); |
|
1263 |
break; |
|
1264 |
||
1265 |
case CUSTCURR_TO_EURO: { /* Year to switch to euro */ |
|
1266 |
int val = atoi(str); |
|
1267 |
||
1268 |
_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR)); |
|
1269 |
break; |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1270 |
} |
10645 | 1271 |
} |
1272 |
MarkWholeScreenDirty(); |
|
1273 |
} |
|
4488
6eb5f6192c3a
(svn r6273) Clean up the custom currency window handler a bit
tron
parents:
4444
diff
changeset
|
1274 |
|
10645 | 1275 |
virtual void OnTimeout() |
1276 |
{ |
|
1277 |
this->click = 0; |
|
1278 |
this->SetDirty(); |
|
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1279 |
} |
10645 | 1280 |
}; |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1281 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1282 |
static const Widget _cust_currency_widgets[] = { |
4344
5d0e40cd67b9
(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
|
1283 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(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
|
1284 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 229, 0, 13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(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
|
1285 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 229, 14, 119, 0x0, STR_NULL}, |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1286 |
{ WIDGETS_END}, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1287 |
}; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1288 |
|
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1289 |
static const WindowDesc _cust_currency_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
1290 |
WDP_CENTER, WDP_CENTER, 230, 120, 230, 120, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5939
diff
changeset
|
1291 |
WC_CUSTOM_CURRENCY, WC_NONE, |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1292 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1293 |
_cust_currency_widgets, |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1294 |
}; |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1295 |
|
6573 | 1296 |
static void ShowCustCurrency() |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1297 |
{ |
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1298 |
DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
10645 | 1299 |
new CustomCurrencyWindow(&_cust_currency_desc); |
759
6d087784a08a
(svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents:
654
diff
changeset
|
1300 |
} |