annotate src/settings_gui.cpp @ 10660:13267d179635 draft

(svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
author rubidium <rubidium@openttd.org>
date Sat, 10 Jan 2009 16:39:18 +0000 (2009-01-10)
parents b800143c7941
children ba3579a2b84f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9092
diff changeset
3 /** @file settings_gui.cpp GUI for settings. */
6420
080aae477331 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas <belugas@openttd.org>
parents: 6378
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "currency.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
9 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
10 #include "textbuf_gui.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
11 #include "command_func.h"
8786
e2d4956b7251 (svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium <rubidium@openttd.org>
parents: 8785
diff changeset
12 #include "engine_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "screenshot.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "newgrf.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
15 #include "network/network.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
16 #include "town.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17 #include "variables.h"
8208
ddc34919158f (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents: 8191
diff changeset
18 #include "settings_internal.h"
6956
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
19 #include "newgrf_townname.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
20 #include "strings_func.h"
8131
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8130
diff changeset
21 #include "functions.h"
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8130
diff changeset
22 #include "window_func.h"
8213
87c85bb42d6f (svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium <rubidium@openttd.org>
parents: 8208
diff changeset
23 #include "core/alloc_func.hpp"
8214
6385dffc0b37 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium <rubidium@openttd.org>
parents: 8213
diff changeset
24 #include "string_func.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
25 #include "gfx_func.h"
8505
1a32b4c9019b (svn r12080) -Fix: update waypoint signs when changing language
glx <glx@openttd.org>
parents: 8424
diff changeset
26 #include "waypoint.h"
8321
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8319
diff changeset
27 #include "widgets/dropdown_type.h"
8284
dbb7bfe0e95c (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138 <peter1138@openttd.org>
parents: 8264
diff changeset
28 #include "widgets/dropdown_func.h"
8785
2a8950a812dc (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents: 8648
diff changeset
29 #include "station_func.h"
10558
15517829eb17 (svn r14815) -Codechange: separate 'highscore' code from 'company' code
smatz <smatz@openttd.org>
parents: 10543
diff changeset
30 #include "highscore.h"
9581
9a3e1ee617ce (svn r13618) -Codechange: move tar-specific declarations to separate file
smatz <smatz@openttd.org>
parents: 9533
diff changeset
31 #include <map>
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
33 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
34 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
35
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
36 static const StringID _units_dropdown[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37 STR_UNITS_IMPERIAL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 STR_UNITS_METRIC,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
39 STR_UNITS_SI,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
43 static const StringID _driveside_dropdown[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
44 STR_02E9_DRIVE_ON_LEFT,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45 STR_02EA_DRIVE_ON_RIGHT,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 static const StringID _autosave_dropdown[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 STR_02F7_OFF,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 STR_AUTOSAVE_1_MONTH,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52 STR_02F8_EVERY_3_MONTHS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 STR_02F9_EVERY_6_MONTHS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 STR_02FA_EVERY_12_MONTHS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55 INVALID_STRING_ID,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58 static const StringID _designnames_dropdown[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59 STR_02BE_DEFAULT,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 STR_02BF_CUSTOM,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 static StringID *BuildDynamicDropdown(StringID base, int num)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 static StringID buf[32 + 1];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 StringID *p = buf;
8969
01cc3ee6ecb1 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents: 8881
diff changeset
68 while (--num >= 0) *p++ = base++;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69 *p = INVALID_STRING_ID;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 return buf;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72
6956
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
73 int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
74 static StringID *_grf_names = NULL;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
75 static int _nb_grf_names = 0;
6797
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
76
8323
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
77 void InitGRFTownGeneratorNames()
6797
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
78 {
6956
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
79 free(_grf_names);
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
80 _grf_names = GetGRFTownNameList();
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
81 _nb_grf_names = 0;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
82 for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
83 }
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
84
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
85 static inline StringID TownName(int town_name)
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
86 {
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
87 if (town_name < _nb_orig_names) return STR_TOWNNAME_ORIGINAL_ENGLISH + town_name;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
88 town_name -= _nb_orig_names;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
89 if (town_name < _nb_grf_names) return _grf_names[town_name];
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
90 return STR_UNDEFINED;
6797
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
91 }
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
92
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
93 static int GetCurRes()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 int i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97 for (i = 0; i != _num_resolutions; i++) {
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9466
diff changeset
98 if (_resolutions[i].width == _screen.width &&
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9466
diff changeset
99 _resolutions[i].height == _screen.height) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103 return i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
106 enum GameOptionsWidgets {
8336
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
107 GAMEOPT_CURRENCY_BTN = 4,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
108 GAMEOPT_DISTANCE_BTN = 6,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
109 GAMEOPT_ROADSIDE_BTN = 8,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
110 GAMEOPT_TOWNNAME_BTN = 10,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
111 GAMEOPT_AUTOSAVE_BTN = 12,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
112 GAMEOPT_VEHICLENAME_BTN = 14,
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
113 GAMEOPT_VEHICLENAME_SAVE,
8336
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
114 GAMEOPT_LANG_BTN = 17,
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
115 GAMEOPT_RESOLUTION_BTN = 19,
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
116 GAMEOPT_FULLSCREEN,
8336
4f73dcb0e148 (svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents: 8323
diff changeset
117 GAMEOPT_SCREENSHOT_BTN = 22,
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
118 };
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
119
8321
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8319
diff changeset
120 /**
8323
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
121 * Update/redraw the townnames dropdown
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
122 * @param w the window the dropdown belongs to
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
123 * @param sel the currently selected townname generator
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
124 */
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
125 static void ShowTownnameDropdown(Window *w, int sel)
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
126 {
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
127 typedef std::map<StringID, int, StringIDCompare> TownList;
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
128 TownList townnames;
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
129
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
130 /* Add and sort original townnames generators */
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
131 for (int i = 0; i < _nb_orig_names; i++) townnames[STR_TOWNNAME_ORIGINAL_ENGLISH + i] = i;
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
132
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
133 /* Add and sort newgrf townnames generators */
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
134 for (int i = 0; i < _nb_grf_names; i++) townnames[_grf_names[i]] = _nb_orig_names + i;
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
135
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
136 DropDownList *list = new DropDownList();
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
137 for (TownList::iterator it = townnames.begin(); it != townnames.end(); it++) {
10407
046ab3a414b7 (svn r14658) -Change: allow changing town names when there are no towns in the scenario yet.
rubidium <rubidium@openttd.org>
parents: 10358
diff changeset
138 list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || GetNumTowns() == 0 || (*it).second == sel)));
8323
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
139 }
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
140
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
141 ShowDropDownList(w, list, sel, GAMEOPT_TOWNNAME_BTN);
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
142 }
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
143
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
144 static void ShowCustCurrency();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
145
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
146 struct GameOptionsWindow : Window {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
147 GameSettings *opt;
9346
0c181c088ed8 (svn r13242) -Codechange: remove _opt_ptr.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
148
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
149 GameOptionsWindow(const WindowDesc *desc) : Window(desc)
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
150 {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
151 this->opt = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
152 this->FindWindowPlacementAndResize(desc);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
153 }
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
154
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
155 ~GameOptionsWindow()
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
156 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
157 DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
158 }
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
159
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
160 virtual void OnPaint()
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
161 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
162 StringID str = STR_02BE_DEFAULT;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
164 this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1));
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
165 if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
166 SetDParam(0, str);
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
167 SetDParam(1, _currency_specs[this->opt->locale.currency].name);
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
168 SetDParam(2, STR_UNITS_IMPERIAL + this->opt->locale.units);
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
169 SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->vehicle.road_side);
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
170 SetDParam(4, TownName(this->opt->game_creation.town_name));
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
171 SetDParam(5, _autosave_dropdown[_settings_client.gui.autosave]);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
172 SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
173 int i = GetCurRes();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
174 SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
175 SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
176 this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
177
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
178 this->DrawWidgets();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
179 DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
180 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
181
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
182 virtual void OnClick(Point pt, int widget)
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
183 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
184 switch (widget) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
185 case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
186 ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->locale.currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
187 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
188
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
189 case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
190 ShowDropDownMenu(this, _units_dropdown, this->opt->locale.units, GAMEOPT_DISTANCE_BTN, 0, 0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
191 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
192
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
193 case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
194 int i = 0;
9298
b2a46cf9b23e (svn r13166) -Codechange: CmdSetRoadDriveSide belongs in road_cmd.cpp, not settings_gui.cpp.
rubidium <rubidium@openttd.org>
parents: 9291
diff changeset
195 extern bool RoadVehiclesAreBuilt();
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
196
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
197 /* You can only change the drive side if you are in the menu or ingame with
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
198 * no vehicles present. In a networking game only the server can change it */
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
199 if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
200 i = (-1) ^ (1 << this->opt->vehicle.road_side); // disable the other value
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
201 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
202
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
203 ShowDropDownMenu(this, _driveside_dropdown, this->opt->vehicle.road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
204 } break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
205
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
206 case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
207 ShowTownnameDropdown(this, this->opt->game_creation.town_name);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
208 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
209
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
210 case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
211 ShowDropDownMenu(this, _autosave_dropdown, _settings_client.gui.autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
212 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
213
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
214 case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
215 ShowDropDownMenu(this, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
216 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
217
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
218 case GAMEOPT_VEHICLENAME_SAVE: // Save customized vehicle-names to disk
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
219 break; // not implemented
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
220
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
221 case GAMEOPT_LANG_BTN: { // Setup interface language dropdown
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
222 typedef std::map<StringID, int, StringIDCompare> LangList;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
223
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
224 /* Sort language names */
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
225 LangList langs;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
226 for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
227
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
228 DropDownList *list = new DropDownList();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
229 for (LangList::iterator it = langs.begin(); it != langs.end(); it++) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
230 list->push_back(new DropDownListStringItem((*it).first, (*it).second, false));
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
231 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
232
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
233 ShowDropDownList(this, list, _dynlang.curr, GAMEOPT_LANG_BTN);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
234 } break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
235
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
236 case GAMEOPT_RESOLUTION_BTN: // Setup resolution dropdown
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
237 ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
238 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
239
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
240 case GAMEOPT_FULLSCREEN: // Click fullscreen on/off
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
241 /* try to toggle full-screen on/off */
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
242 if (!ToggleFullScreen(!_fullscreen)) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
243 ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
244 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
245 this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
246 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
247 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
248
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
249 case GAMEOPT_SCREENSHOT_BTN: // Setup screenshot format dropdown
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
250 ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
251 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
252 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
253 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
254
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
255 virtual void OnDropdownSelect(int widget, int index)
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
256 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
257 switch (widget) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
258 case GAMEOPT_VEHICLENAME_BTN: // Vehicle design names
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
259 if (index == 0) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
260 DeleteCustomEngineNames();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
261 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
262 } else if (!(_vehicle_design_names & 1)) {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
263 LoadCustomEngineNames();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
264 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
265 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
266 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
267
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
268 case GAMEOPT_CURRENCY_BTN: /* Currency */
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
269 if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
270 this->opt->locale.currency = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
271 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
272 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
273
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
274 case GAMEOPT_DISTANCE_BTN: // Measuring units
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9421
diff changeset
275 this->opt->locale.units = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
276 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
277 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
278
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
279 case GAMEOPT_ROADSIDE_BTN: // Road side
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
280 if (this->opt->vehicle.road_side != index) { // only change if setting changed
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10407
diff changeset
281 DoCommandP(0, index, 0, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
282 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
283 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
284 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
285
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
286 case GAMEOPT_TOWNNAME_BTN: // Town names
10407
046ab3a414b7 (svn r14658) -Change: allow changing town names when there are no towns in the scenario yet.
rubidium <rubidium@openttd.org>
parents: 10358
diff changeset
287 if (_game_mode == GM_MENU || GetNumTowns() == 0) {
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
288 this->opt->game_creation.town_name = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
289 InvalidateWindow(WC_GAME_OPTIONS, 0);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
290 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
291 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
292
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
293 case GAMEOPT_AUTOSAVE_BTN: // Autosave options
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
294 _settings_client.gui.autosave = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
295 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
296 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
297
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
298 case GAMEOPT_LANG_BTN: // Change interface language
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
299 ReadLanguagePack(index);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
300 CheckForMissingGlyphsInLoadedLanguagePack();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
301 UpdateAllStationVirtCoord();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
302 UpdateAllWaypointSigns();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
303 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
304 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
305
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
306 case GAMEOPT_RESOLUTION_BTN: // Change resolution
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9466
diff changeset
307 if (index < _num_resolutions && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
308 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
309 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
310 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
311
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
312 case GAMEOPT_SCREENSHOT_BTN: // Change screenshot format
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
313 SetScreenshotFormat(index);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
314 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
315 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
316 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
317 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
318 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
319
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
320 static const Widget _game_options_widgets[] = {
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
321 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
322 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
323 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 369, 14, 238, 0x0, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
324 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
325 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
326 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
327 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
328 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
329 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
330 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
331 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
332 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
333 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
334
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
335 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 359, 194, 228, STR_02BC_VEHICLE_DESIGN_NAMES, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
336 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 119, 207, 218, STR_02BD, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
337 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 130, 349, 207, 218, STR_02C0_SAVE_CUSTOM_NAMES, STR_02C2_SAVE_CUSTOMIZED_VEHICLE},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
338
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
339 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
340 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
341
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
342 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
343 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
344 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
345
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
346 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
347 { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
348
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
349 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
350 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
351
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
352 static const WindowDesc _game_options_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7177
diff changeset
353 WDP_CENTER, WDP_CENTER, 370, 239, 370, 239,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
354 WC_GAME_OPTIONS, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
356 _game_options_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
358
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
359
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
360 void ShowGameOptions()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
361 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
362 DeleteWindowById(WC_GAME_OPTIONS, 0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
363 new GameOptionsWindow(&_game_options_desc);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
364 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
365
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
366 extern void StartupEconomy();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
367
8136
e96bc0580891 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13 <skidd13@openttd.org>
parents: 8131
diff changeset
368 /* Widget definition for the game difficulty settings window */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
369 static const Widget _game_difficulty_widgets[] = {
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
370 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // GDW_CLOSEBOX
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
371 { WWT_CAPTION, RESIZE_NONE, COLOUR_MAUVE, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
372 { WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 14, 41, 0x0, STR_NULL}, // GDW_UPPER_BG
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
373 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 96, 16, 27, STR_6801_EASY, STR_NULL}, // GDW_LVL_EASY
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
374 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 97, 183, 16, 27, STR_6802_MEDIUM, STR_NULL}, // GDW_LVL_MEDIUM
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
375 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 184, 270, 16, 27, STR_6803_HARD, STR_NULL}, // GDW_LVL_HARD
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
376 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 271, 357, 16, 27, STR_6804_CUSTOM, STR_NULL}, // GDW_LVL_CUSTOM
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
377 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREEN, 10, 357, 28, 39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL}, // GDW_HIGHSCORE
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
378 { WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 42, 262, 0x0, STR_NULL}, // GDW_SETTING_BG
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
379 { WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 263, 278, 0x0, STR_NULL}, // GDW_LOWER_BG
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
380 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 105, 185, 265, 276, STR_OPTIONS_SAVE_CHANGES, STR_NULL}, // GDW_ACCEPT
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
381 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 186, 266, 265, 276, STR_012E_CANCEL, STR_NULL}, // GDW_CANCEL
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384
8136
e96bc0580891 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13 <skidd13@openttd.org>
parents: 8131
diff changeset
385 /* Window definition for the game difficulty settings window */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
386 static const WindowDesc _game_difficulty_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7177
diff changeset
387 WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
388 WC_GAME_OPTIONS, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
389 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 _game_difficulty_widgets,
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
391 };
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
392
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
393 void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
394
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
395 struct GameDifficultyWindow : public Window {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
396 private:
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
397 static const uint GAME_DIFFICULTY_NUM = 18;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
398 bool clicked_increase;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
399 uint8 clicked_button;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
400 uint8 timeout;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
401
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
402 /* Temporary holding place of values in the difficulty window until 'Save' is clicked */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
403 GameSettings opt_mod_temp;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
404
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
405 enum {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
406 GAMEDIFF_WND_TOP_OFFSET = 45,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
407 GAMEDIFF_WND_ROWSIZE = 9,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
408 NO_SETTINGS_BUTTON = 0xFF,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
409 };
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
410
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
411 /* Names of the game difficulty settings window */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
412 enum GameDifficultyWidgets {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
413 GDW_CLOSEBOX = 0,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
414 GDW_CAPTION,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
415 GDW_UPPER_BG,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
416 GDW_LVL_EASY,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
417 GDW_LVL_MEDIUM,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
418 GDW_LVL_HARD,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
419 GDW_LVL_CUSTOM,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
420 GDW_HIGHSCORE,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
421 GDW_SETTING_BG,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
422 GDW_LOWER_BG,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
423 GDW_ACCEPT,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
424 GDW_CANCEL,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
425 };
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
426
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
427 public:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
428 GameDifficultyWindow() : Window(&_game_difficulty_desc)
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
429 {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
430 /* Copy current settings (ingame or in intro) to temporary holding place
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
431 * change that when setting stuff, copy back on clicking 'OK' */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
432 this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
433 this->clicked_increase = false;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
434 this->clicked_button = NO_SETTINGS_BUTTON;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
435 this->timeout = 0;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
436 /* Hide the closebox to make sure that the user aborts or confirms his changes */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
437 this->HideWidget(GDW_CLOSEBOX);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
438 this->widget[GDW_CAPTION].left = 0;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
439 /* Setup disabled buttons when creating window
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
440 * disable all other difficulty buttons during gameplay except for 'custom' */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
441 this->SetWidgetsDisabledState(_game_mode == GM_NORMAL,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
442 GDW_LVL_EASY,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
443 GDW_LVL_MEDIUM,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
444 GDW_LVL_HARD,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
445 GDW_LVL_CUSTOM,
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
446 WIDGET_LIST_END);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
447 this->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
448 this->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
449 this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
450 this->FindWindowPlacementAndResize(&_game_difficulty_desc);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
451 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
452
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
453 virtual void OnPaint()
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
454 {
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9246
diff changeset
455 this->DrawWidgets();
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
456
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
457 uint i;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
458 const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
459 int y = GAMEDIFF_WND_TOP_OFFSET;
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
460 for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
461 const SettingDescBase *sdb = &sd->desc;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
462 int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
463 bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
464
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
465 DrawArrowButtons(5, y, COLOUR_YELLOW,
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
466 (this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
467 editable && sdb->min != value,
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
468 editable && sdb->max != value);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
469
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
470 value += sdb->str;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
471 SetDParam(0, value);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
472 DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
473
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
474 y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
475 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
476 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
477
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
478 virtual void OnClick(Point pt, int widget)
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
479 {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
480 switch (widget) {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
481 case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
482 /* Don't allow clients to make any changes */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
483 if (_networking && !_network_server) return;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
484
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
485 const int x = pt.x - 5;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
486 if (!IsInsideMM(x, 0, 21)) return; // Button area
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
487
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
488 const int y = pt.y - GAMEDIFF_WND_TOP_OFFSET;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
489 if (y < 0) return;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
490
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
491 /* Get button from Y coord. */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
492 const uint8 btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
493 if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) return;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
494
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
495 uint i;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
496 const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i) + btn;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
497 const SettingDescBase *sdb = &sd->desc;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
498
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
499 /* Clicked disabled button? */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
500 bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
501 if (!editable) return;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
502
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
503 this->timeout = 5;
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
504 int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
505
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
506 if (x >= 10) {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
507 /* Increase button clicked */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
508 val = min(val + sdb->interval, sdb->max);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
509 this->clicked_increase = true;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
510 } else {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
511 /* Decrease button clicked */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
512 val -= sdb->interval;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
513 val = max(val, sdb->min);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
514 this->clicked_increase = false;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
515 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
516 this->clicked_button = btn;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
517
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
518 /* save value in temporary variable */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
519 WriteValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv, val);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
520 this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
521 SetDifficultyLevel(3, &this->opt_mod_temp.difficulty); // set difficulty level to custom
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
522 this->LowerWidget(GDW_LVL_CUSTOM);
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
523 this->SetDirty();
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
524 } break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
525
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
526 case GDW_LVL_EASY:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
527 case GDW_LVL_MEDIUM:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
528 case GDW_LVL_HARD:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
529 case GDW_LVL_CUSTOM:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
530 /* temporarily change difficulty level */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
531 this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
532 SetDifficultyLevel(widget - GDW_LVL_EASY, &this->opt_mod_temp.difficulty);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
533 this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
534 this->SetDirty();
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
535 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
536
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
537 case GDW_HIGHSCORE: // Highscore Table
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
538 ShowHighscoreTable(this->opt_mod_temp.difficulty.diff_level, -1);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
539 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
540
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
541 case GDW_ACCEPT: { // Save button - save changes
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
542 GameSettings *opt_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
543
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
544 uint i;
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
545 const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
546 for (uint btn = 0; btn != GAME_DIFFICULTY_NUM; btn++, sd++) {
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
547 int32 new_val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
548 int32 cur_val = (int32)ReadValue(GetVariableAddress(opt_ptr, &sd->save), sd->save.conv);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
549 /* if setting has changed, change it */
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
550 if (new_val != cur_val) {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10407
diff changeset
551 DoCommandP(0, i + btn, new_val, CMD_CHANGE_PATCH_SETTING);
9346
0c181c088ed8 (svn r13242) -Codechange: remove _opt_ptr.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
552 }
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
553 }
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
554
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
555 GetPatchFromName("difficulty.diff_level", &i);
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10407
diff changeset
556 DoCommandP(0, i, this->opt_mod_temp.difficulty.diff_level, CMD_CHANGE_PATCH_SETTING);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
557 delete this;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
558 /* If we are in the editor, we should reload the economy.
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
559 * This way when you load a game, the max loan and interest rate
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
560 * are loaded correctly. */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
561 if (_game_mode == GM_EDITOR) StartupEconomy();
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
562 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
563 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
564
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
565 case GDW_CANCEL: // Cancel button - close window, abandon changes
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
566 delete this;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
567 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
568 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
569 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
570
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
571 virtual void OnTick()
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
572 {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
573 if (this->timeout != 0) {
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
574 this->timeout--;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
575 if (this->timeout == 0) this->clicked_button = NO_SETTINGS_BUTTON;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
576 this->SetDirty();
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
577 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
578 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
580
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
581 void ShowGameDifficulty()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583 DeleteWindowById(WC_GAME_OPTIONS, 0);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
584 new GameDifficultyWindow();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586
10538
24ddd67a00be (svn r14795) -Codechange: replace a magic number with a constant (Alberth)
rubidium <rubidium@openttd.org>
parents: 10537
diff changeset
587 static const int SETTING_HEIGHT = 11; ///< Height of a single patch setting in the tree view
24ddd67a00be (svn r14795) -Codechange: replace a magic number with a constant (Alberth)
rubidium <rubidium@openttd.org>
parents: 10537
diff changeset
588
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
589 /** Flags for #PatchEntry */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
590 enum PatchEntryFlags {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
591 PEF_LAST_FIELD = 0x04, ///< This entry is the last one in a (sub-)page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
592
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
593 /* Entry kind */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
594 PEF_SETTING_KIND = 0x10, ///< Entry kind: Entry is a setting
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
595 PEF_SUBTREE_KIND = 0x20, ///< Entry kind: Entry is a sub-tree
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
596 PEF_KIND_MASK = (PEF_SETTING_KIND | PEF_SUBTREE_KIND), ///< Bit-mask for fetching entry kind
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
597 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
598
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
599 struct PatchPage; // Forward declaration
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
600
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
601 /** Data fields for a sub-page (#PEF_SUBTREE_KIND kind)*/
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
602 struct PatchEntrySubtree {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
603 PatchPage *page; ///< Pointer to the sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
604 bool folded; ///< Sub-page is folded (not visible except for its title)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
605 StringID title; ///< Title of the sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
606 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
607
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
608 /** Data fields for a single setting (#PEF_SETTING_KIND kind) */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
609 struct PatchEntrySetting {
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
610 const char *name; ///< Name of the setting
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
611 const SettingDesc *setting; ///< Setting description of the setting
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
612 uint index; ///< Index of the setting in the settings table
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
613 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
614
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
615 /** Data structure describing a single patch in a tab */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
616 struct PatchEntry {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
617 byte flags; ///< Flags of the patch entry. @see PatchEntryFlags
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
618 byte level; ///< Nesting level of this patch entry
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
619 union {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
620 PatchEntrySetting entry; ///< Data fields if entry is a setting
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
621 PatchEntrySubtree sub; ///< Data fields if entry is a sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
622 } d; ///< Data fields for each kind
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
623
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
624 PatchEntry(const char *nm);
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
625 PatchEntry(PatchPage *sub, StringID title);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
626
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
627 void Init(byte level, bool last_field);
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
628 };
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
629
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
630 /** Data structure describing one page of patches in the patch settings window. */
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
631 struct PatchPage {
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
632 PatchEntry *entries; ///< Array of patch entries of the page.
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
633 byte num; ///< Number of entries on the page (statically filled).
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
634
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
635 void Init(byte level = 0);
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
636 };
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
637
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
638
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
639 /* == PatchEntry methods == */
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
640
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
641 /**
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
642 * Constructor for a single setting in the 'advanced settings' window
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
643 * @param nm Name of the setting in the setting table
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
644 */
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
645 PatchEntry::PatchEntry(const char *nm)
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
646 {
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
647 this->flags = PEF_SETTING_KIND;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
648 this->level = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
649 this->d.entry.name = nm;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
650 this->d.entry.setting = NULL;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
651 this->d.entry.index = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
652 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
653
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
654 /**
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
655 * Constructor for a sub-page in the 'advanced settings' window
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
656 * @param sub Sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
657 * @param title Title of the sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
658 */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
659 PatchEntry::PatchEntry(PatchPage *sub, StringID title)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
660 {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
661 this->flags = PEF_SUBTREE_KIND;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
662 this->level = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
663 this->d.sub.page = sub;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
664 this->d.sub.folded = true;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
665 this->d.sub.title = title;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
666 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
667
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
668 /**
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
669 * Initialization of a patch entry
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
670 * @param level Page nesting level of this entry
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
671 * @param last_field Boolean indicating this entry is the last at the (sub-)page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
672 */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
673 void PatchEntry::Init(byte level, bool last_field)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
674 {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
675 this->level = level;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
676 if (last_field) this->flags |= PEF_LAST_FIELD;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
677
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
678 switch (this->flags & PEF_KIND_MASK) {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
679 case PEF_SETTING_KIND:
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
680 this->d.entry.setting = GetPatchFromName(this->d.entry.name, &this->d.entry.index);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
681 assert(this->d.entry.setting != NULL);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
682 break;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
683 case PEF_SUBTREE_KIND:
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
684 this->d.sub.page->Init(level + 1);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
685 break;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
686 default: NOT_REACHED();
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
687 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
688 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
689
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
690
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
691 /* == PatchPage methods == */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
692
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
693 /**
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
694 * Initialization of an entire setting page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
695 * @param level Nesting level of this page (internal variable, do not provide a value for it when calling)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
696 */
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
697 void PatchPage::Init(byte level)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
698 {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
699 for (uint field = 0; field < this->num; field++) {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
700 this->entries[field].Init(level, field + 1 == num);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
701 }
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
702 }
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
703
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
704
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
705 static PatchEntry _patches_ui[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
706 PatchEntry("gui.vehicle_speed"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
707 PatchEntry("gui.status_long_date"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
708 PatchEntry("gui.date_format_in_default_names"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
709 PatchEntry("gui.show_finances"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
710 PatchEntry("gui.autoscroll"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
711 PatchEntry("gui.reverse_scroll"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
712 PatchEntry("gui.smooth_scroll"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
713 PatchEntry("gui.errmsg_duration"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
714 PatchEntry("gui.toolbar_pos"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
715 PatchEntry("gui.measure_tooltip"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
716 PatchEntry("gui.window_snap_radius"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
717 PatchEntry("gui.window_soft_limit"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
718 PatchEntry("gui.population_in_label"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
719 PatchEntry("gui.link_terraform_toolbar"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
720 PatchEntry("gui.liveries"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
721 PatchEntry("gui.prefer_teamchat"),
6289
7830dc08984a (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni <bjarni@openttd.org>
parents: 6259
diff changeset
722 /* While the horizontal scrollwheel scrolling is written as general code, only
7830dc08984a (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni <bjarni@openttd.org>
parents: 6259
diff changeset
723 * the cocoa (OSX) driver generates input for it.
6296
94f5e47fddaa (svn r9126) -Feature: "Function of scrollwheel" can now be set to off as well
bjarni <bjarni@openttd.org>
parents: 6293
diff changeset
724 * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
725 PatchEntry("gui.scrollwheel_scrolling"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
726 PatchEntry("gui.scrollwheel_multiplier"),
7485
f7dd4bbc720d (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni <bjarni@openttd.org>
parents: 7341
diff changeset
727 #ifdef __APPLE__
f7dd4bbc720d (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni <bjarni@openttd.org>
parents: 7341
diff changeset
728 /* We might need to emulate a right mouse button on mac */
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
729 PatchEntry("gui.right_mouse_btn_emulation"),
7485
f7dd4bbc720d (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni <bjarni@openttd.org>
parents: 7341
diff changeset
730 #endif
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
731 PatchEntry("gui.pause_on_newgame"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
732 PatchEntry("gui.advanced_vehicle_list"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
733 PatchEntry("gui.loading_indicators"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
734 PatchEntry("gui.timetable_in_ticks"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
735 PatchEntry("gui.quick_goto"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
736 PatchEntry("gui.default_rail_type"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
737 PatchEntry("gui.always_build_infrastructure"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
738 PatchEntry("gui.persistent_buildingtools"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
739 PatchEntry("gui.show_track_reservation"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
740 PatchEntry("gui.left_mouse_btn_scrolling"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
741 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
742
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
743 static PatchEntry _patches_construction[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
744 PatchEntry("construction.build_on_slopes"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
745 PatchEntry("construction.autoslope"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
746 PatchEntry("construction.extra_dynamite"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
747 PatchEntry("construction.longbridges"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
748 PatchEntry("construction.signal_side"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
749 PatchEntry("station.always_small_airport"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
750 PatchEntry("gui.enable_signal_gui"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
751 PatchEntry("gui.drag_signals_density"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
752 PatchEntry("game_creation.oil_refinery_limit"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
753 PatchEntry("gui.semaphore_build_before"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
754 PatchEntry("gui.default_signal_type"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
755 PatchEntry("gui.cycle_signal_types"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
756 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
758 static PatchEntry _patches_stations[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
759 PatchEntry("station.join_stations"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
760 PatchEntry("order.improved_load"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
761 PatchEntry("order.selectgoods"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
762 PatchEntry("gui.new_nonstop"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
763 PatchEntry("station.nonuniform_stations"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
764 PatchEntry("station.station_spread"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
765 PatchEntry("order.serviceathelipad"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
766 PatchEntry("station.modified_catchment"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
767 PatchEntry("order.gradual_loading"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
768 PatchEntry("construction.road_stop_on_town_road"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
769 PatchEntry("station.adjacent_stations"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
770 PatchEntry("station.distant_join_stations"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
771 PatchEntry("economy.station_noise_level"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
772 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
774 static PatchEntry _patches_economy[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
775 PatchEntry("economy.inflation"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
776 PatchEntry("construction.raw_industry_construction"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
777 PatchEntry("economy.multiple_industry_per_town"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
778 PatchEntry("economy.same_industry_close"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
779 PatchEntry("economy.bribe"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
780 PatchEntry("economy.exclusive_rights"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
781 PatchEntry("economy.give_money"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
782 PatchEntry("gui.colored_news_year"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
783 PatchEntry("economy.smooth_economy"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
784 PatchEntry("economy.allow_shares"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
785 PatchEntry("economy.town_layout"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
786 PatchEntry("economy.mod_road_rebuild"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
787 PatchEntry("economy.town_growth_rate"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
788 PatchEntry("economy.larger_towns"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
789 PatchEntry("economy.initial_city_size"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
790 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
791
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
792 static PatchEntry _patches_ai[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
793 PatchEntry("ai.ainew_active"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
794 PatchEntry("ai.ai_in_multiplayer"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
795 PatchEntry("ai.ai_disable_veh_train"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
796 PatchEntry("ai.ai_disable_veh_roadveh"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
797 PatchEntry("ai.ai_disable_veh_aircraft"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
798 PatchEntry("ai.ai_disable_veh_ship"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
799 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
801 static PatchEntry _patches_vehicles[] = {
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
802 PatchEntry("vehicle.realistic_acceleration"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
803 PatchEntry("pf.forbid_90_deg"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
804 PatchEntry("vehicle.mammoth_trains"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
805 PatchEntry("order.gotodepot"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
806 PatchEntry("pf.roadveh_queue"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
807 PatchEntry("pf.pathfinder_for_trains"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
808 PatchEntry("pf.pathfinder_for_roadvehs"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
809 PatchEntry("pf.pathfinder_for_ships"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
810 PatchEntry("gui.vehicle_income_warn"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
811 PatchEntry("gui.order_review_system"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
812 PatchEntry("vehicle.never_expire_vehicles"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
813 PatchEntry("gui.lost_train_warn"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
814 PatchEntry("gui.autorenew"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
815 PatchEntry("gui.autorenew_months"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
816 PatchEntry("gui.autorenew_money"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
817 PatchEntry("vehicle.max_trains"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
818 PatchEntry("vehicle.max_roadveh"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
819 PatchEntry("vehicle.max_aircraft"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
820 PatchEntry("vehicle.max_ships"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
821 PatchEntry("vehicle.servint_ispercent"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
822 PatchEntry("vehicle.servint_trains"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
823 PatchEntry("vehicle.servint_roadveh"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
824 PatchEntry("vehicle.servint_ships"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
825 PatchEntry("vehicle.servint_aircraft"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
826 PatchEntry("order.no_servicing_if_no_breakdowns"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
827 PatchEntry("vehicle.wagon_speed_limits"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
828 PatchEntry("vehicle.disable_elrails"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
829 PatchEntry("vehicle.freight_trains"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
830 PatchEntry("vehicle.plane_speed"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
831 PatchEntry("order.timetabling"),
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
832 PatchEntry("vehicle.dynamic_engines"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
834
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
835 /** Array of pages (tabs), where each page holds a number of advanced settings. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836 static PatchPage _patches_page[] = {
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
837 {_patches_ui, lengthof(_patches_ui)},
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
838 {_patches_construction, lengthof(_patches_construction)},
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
839 {_patches_vehicles, lengthof(_patches_vehicles)},
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
840 {_patches_stations, lengthof(_patches_stations)},
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
841 {_patches_economy, lengthof(_patches_economy)},
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
842 {_patches_ai, lengthof(_patches_ai)},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
843 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
844
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
845 /** Widget numbers of config patches window */
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
846 enum PatchesSelectionWidgets {
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
847 PATCHSEL_OPTIONSPANEL = 3, ///< Panel widget containing the option lists
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
848 PATCHSEL_SCROLLBAR, ///< Scrollbar
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
849 PATCHSEL_RESIZE, ///< Resize button
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
850 PATCHSEL_INTERFACE, ///< Button 'Interface'
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
851 PATCHSEL_CONSTRUCTION, ///< Button 'Construction'
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
852 PATCHSEL_VEHICLES, ///< Button 'Vehicles'
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
853 PATCHSEL_STATIONS, ///< Button 'Stations'
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
854 PATCHSEL_ECONOMY, ///< Button 'Economy'
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
855 PATCHSEL_COMPETITORS ///< Button 'Competitors'
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
856 };
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
857
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
858 struct PatchesSelectionWindow : Window {
10540
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
859 static const int SETTINGTREE_LEFT_OFFSET; ///< Position of left edge of patch values
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
860 static const int SETTINGTREE_TOP_OFFSET; ///< Position of top edge of patch values
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
861
10537
99847a2606d5 (svn r14794) -Document: a few functions/variables (Alberth)
rubidium <rubidium@openttd.org>
parents: 10535
diff changeset
862 static GameSettings *patches_ptr; ///< Pointer to the game settings being displayed and modified
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
863
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
864 int page;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
865 int entry;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
866 int click;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
867
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
868 PatchesSelectionWindow(const WindowDesc *desc) : Window(desc)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
869 {
10540
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
870 /* Check that the widget doesn't get moved without adapting the constant as well.
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
871 * - SETTINGTREE_LEFT_OFFSET should be 5 pixels to the right of the left edge of the panel
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
872 * - SETTINGTREE_TOP_OFFSET should be 5 pixels below the top edge of the panel
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
873 */
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
874 assert(this->widget[PATCHSEL_OPTIONSPANEL].left + 5 == SETTINGTREE_LEFT_OFFSET);
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
875 assert(this->widget[PATCHSEL_OPTIONSPANEL].top + 5 == SETTINGTREE_TOP_OFFSET);
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
876
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
877 static bool first_time = true;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
878
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
879 patches_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
880
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
881 /* Build up the dynamic settings-array only once per OpenTTD session */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
882 if (first_time) {
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
883 for (PatchPage *page = &_patches_page[0]; page != endof(_patches_page); page++) {
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
884 page->Init();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
885 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
886 first_time = false;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
887 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
888
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
889 this->page = 0;
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
890 this->vscroll.pos = 0;
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
891 this->vscroll.cap = (this->widget[PATCHSEL_OPTIONSPANEL].bottom - this->widget[PATCHSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT;
10658
c59498b89a47 (svn r14960) -Codechange: add some this where appropriate (Alberth)
rubidium <rubidium@openttd.org>
parents: 10638
diff changeset
892 SetVScrollCount(this, _patches_page[this->page].num);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
893
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
894 this->resize.step_height = SETTING_HEIGHT;
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
895 this->resize.height = this->height;
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
896 this->resize.step_width = 1;
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
897 this->resize.width = this->width;
8593
90ffef351faa (svn r12174) -Codechange: Make the patches window dynamically resize to the largest patch tab, so adding patch options is simply a case of adding to the lists.
peter1138 <peter1138@openttd.org>
parents: 8551
diff changeset
898
10658
c59498b89a47 (svn r14960) -Codechange: add some this where appropriate (Alberth)
rubidium <rubidium@openttd.org>
parents: 10638
diff changeset
899 this->LowerWidget(this->page + PATCHSEL_INTERFACE); // Depress button of currently selected page
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
900
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
901 this->FindWindowPlacementAndResize(desc);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
902 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
903
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
904 virtual void OnPaint()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
905 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
906 const PatchPage *page = &_patches_page[this->page];
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
907
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
908 /* Set up selected category */
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9246
diff changeset
909 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
910
10540
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
911 int x = SETTINGTREE_LEFT_OFFSET;
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
912 int y = SETTINGTREE_TOP_OFFSET;
10658
c59498b89a47 (svn r14960) -Codechange: add some this where appropriate (Alberth)
rubidium <rubidium@openttd.org>
parents: 10638
diff changeset
913 for (uint i = this->vscroll.pos; i != page->num && this->vscroll.pos + this->vscroll.cap - i > 0; i++) {
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
914 assert((page->entries[i].flags & PEF_KIND_MASK) == PEF_SETTING_KIND);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
915 const SettingDesc *sd = page->entries[i].d.entry.setting;
10542
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
916 DrawPatch(patches_ptr, sd, x, y, this->click - (i * 2));
10538
24ddd67a00be (svn r14795) -Codechange: replace a magic number with a constant (Alberth)
rubidium <rubidium@openttd.org>
parents: 10537
diff changeset
917 y += SETTING_HEIGHT;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
918 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
919 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
920
10542
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
921 void DrawPatch(GameSettings *patches_ptr, const SettingDesc *sd, int x, int y, int state)
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
922 {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
923 const SettingDescBase *sdb = &sd->desc;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
924 const void *var = GetVariableAddress(patches_ptr, &sd->save);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
925 bool editable = true;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
926 bool disabled = false;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
927
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
928 /* We do not allow changes of some items when we are a client in a networkgame */
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
929 if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
930 if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
931 if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
932
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
933 if (sdb->cmd == SDT_BOOLX) {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
934 static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
935 /* Draw checkbox for boolean-value either on/off */
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
936 bool on = (*(bool*)var);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
937
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
938 DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
939 SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
940 } else {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
941 int32 value;
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
942
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
943 value = (int32)ReadValue(var, sd->save.conv);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
944
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
945 /* Draw [<][>] boxes for settings of an integer-type */
10638
6a6a38ddd2bb (svn r14938) -Fix: some small inconsistencies w.r.t. "0 is disabled" setting handling
rubidium <rubidium@openttd.org>
parents: 10626
diff changeset
946 DrawArrowButtons(x, y, COLOUR_YELLOW, state, editable && value != (sdb->flags & SGF_0ISDISABLED ? 0 : sdb->min), editable && value != sdb->max);
10542
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
947
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
948 disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
949 if (disabled) {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
950 SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
951 } else {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
952 if (sdb->flags & SGF_CURRENCY) {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
953 SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
954 } else if (sdb->flags & SGF_MULTISTRING) {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
955 SetDParam(0, sdb->str + value + 1);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
956 } else {
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
957 SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
958 }
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
959 SetDParam(1, value);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
960 }
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
961 }
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
962 DrawString(x + 25, y, (sdb->str) + disabled, TC_FROMSTRING);
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
963 }
e58198775628 (svn r14799) -Codechange: move drawing a single settings entry to it's own function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10541
diff changeset
964
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
965 virtual void OnClick(Point pt, int widget)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
966 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
967 switch (widget) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
968 case PATCHSEL_OPTIONSPANEL: {
10541
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
969 int y = pt.y - SETTINGTREE_TOP_OFFSET; // Shift y coordinate
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
970 if (y < 0) return; // Clicked above first entry
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
971
10541
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
972 int x = pt.x - SETTINGTREE_LEFT_OFFSET; // Shift x coordinate
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
973 if (x < 0) return; // Clicked left of the entry
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
974
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
975 byte btn = this->vscroll.pos + y / SETTING_HEIGHT; // Compute which setting is selected
10538
24ddd67a00be (svn r14795) -Codechange: replace a magic number with a constant (Alberth)
rubidium <rubidium@openttd.org>
parents: 10537
diff changeset
976 if (y % SETTING_HEIGHT > SETTING_HEIGHT - 2) return; // Clicked too low at the setting
10541
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
977
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
978 const PatchPage *page = &_patches_page[this->page];
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
979
10199
44f6778a8a9d (svn r14412) -Documentation: Comment some functions related to the advanced settings. Patch by Alberth, but with less excessive use of 'at'.
frosch <frosch@openttd.org>
parents: 10180
diff changeset
980 if (btn >= page->num) return; // Clicked below the last setting of the page
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
981
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
982 assert((page->entries[btn].flags & PEF_KIND_MASK) == PEF_SETTING_KIND);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
983 const SettingDesc *sd = page->entries[btn].d.entry.setting;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
984
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
985 /* return if action is only active in network, or only settable by server */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
986 if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
987 if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
988 if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
989
10541
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
990 void *var = GetVariableAddress(patches_ptr, &sd->save);
9742f1fb3d1b (svn r14798) -Codechange: move variable declaration to first use of variable (Alberth)
rubidium <rubidium@openttd.org>
parents: 10540
diff changeset
991 int32 value = (int32)ReadValue(var, sd->save.conv);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
993 /* clicked on the icon on the left side. Either scroller or bool on/off */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
994 if (x < 21) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
995 const SettingDescBase *sdb = &sd->desc;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
996 int32 oldvalue = value;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
997
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
998 switch (sdb->cmd) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
999 case SDT_BOOLX: value ^= 1; break;
10535
7af21a64b4a4 (svn r14792) -Feature: make the date format for default savegame/screenshot names configurable
rubidium <rubidium@openttd.org>
parents: 10532
diff changeset
1000 case SDT_ONEOFMANY:
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1001 case SDT_NUMX: {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1002 /* Add a dynamic step-size to the scroller. In a maximum of
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1003 * 50-steps you should be able to get from min to max,
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1004 * unless specified otherwise in the 'interval' variable
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1005 * of the current patch. */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1006 uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1007 if (step == 0) step = 1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1008
10180
e024f1d28082 (svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents: 10145
diff changeset
1009 /* don't allow too fast scrolling */
e024f1d28082 (svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents: 10145
diff changeset
1010 if ((this->flags4 & WF_TIMEOUT_MASK) > WF_TIMEOUT_TRIGGER) {
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1011 _left_button_clicked = false;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1012 return;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1013 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1015 /* Increase or decrease the value and clamp it to extremes */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1016 if (x >= 10) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1017 value += step;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1018 if (value > sdb->max) value = sdb->max;
10601
7a2c180b90f0 (svn r14885) -Fix: if settings minimum != 1 and 0-is-disabled is enabled, one could set the setting in-game to an out-of-valid-range value.
rubidium <rubidium@openttd.org>
parents: 10581
diff changeset
1019 if (value < sdb->min) value = sdb->min; // skip between "disabled" and minimum
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1020 } else {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1021 value -= step;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1022 if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1023 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1024
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1025 /* Set up scroller timeout for numeric values */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1026 if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1027 this->click = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
10180
e024f1d28082 (svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents: 10145
diff changeset
1028 this->flags4 |= WF_TIMEOUT_BEGIN;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1029 _left_button_clicked = false;
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
1030 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1031 } break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1032 default: NOT_REACHED();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1033 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1034
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1035 if (value != oldvalue) {
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1036 SetPatchValue(page->entries[btn].d.entry.index, value);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1037 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1038 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1039 } else {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1040 /* only open editbox for types that its sensible for */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1041 if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1042 /* Show the correct currency-translated value */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1043 if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1044
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1045 this->entry = btn;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1046 SetDParam(0, value);
10145
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 9872
diff changeset
1047 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, this, CS_NUMERAL, QSF_NONE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1049 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1050 } break;
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
1051
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1052 case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1053 case PATCHSEL_STATIONS: case PATCHSEL_ECONOMY: case PATCHSEL_COMPETITORS:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1054 this->RaiseWidget(this->page + PATCHSEL_INTERFACE);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1055 this->page = widget - PATCHSEL_INTERFACE;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1056 this->LowerWidget(this->page + PATCHSEL_INTERFACE);
10658
c59498b89a47 (svn r14960) -Codechange: add some this where appropriate (Alberth)
rubidium <rubidium@openttd.org>
parents: 10638
diff changeset
1057 SetVScrollCount(this, _patches_page[this->page].num);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1058 DeleteWindowById(WC_QUERY_STRING, 0);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1059 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1060 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1061 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1062 }
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
1063
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1064 virtual void OnTimeout()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1065 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1066 this->click = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1067 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1068 }
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
1069
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1070 virtual void OnQueryTextFinished(char *str)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1071 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1072 if (!StrEmpty(str)) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1073 const PatchEntry *pe = &_patches_page[this->page].entries[this->entry];
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1074 assert((pe->flags & PEF_KIND_MASK) == PEF_SETTING_KIND);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1075 const SettingDesc *sd = pe->d.entry.setting;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1076 int32 value = atoi(str);
8190
eb210e97738e (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas <belugas@openttd.org>
parents: 8189
diff changeset
1077
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1078 /* Save the correct currency-translated value */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1079 if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1080
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1081 SetPatchValue(pe->d.entry.index, value);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1082 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1083 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1084 }
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1085
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1086 virtual void OnResize(Point new_size, Point delta)
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1087 {
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1088 this->vscroll.cap += delta.y / SETTING_HEIGHT;
10658
c59498b89a47 (svn r14960) -Codechange: add some this where appropriate (Alberth)
rubidium <rubidium@openttd.org>
parents: 10638
diff changeset
1089 SetVScrollCount(this, _patches_page[this->page].num);
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1090 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1091 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1092
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9359
diff changeset
1093 GameSettings *PatchesSelectionWindow::patches_ptr = NULL;
10540
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
1094 const int PatchesSelectionWindow::SETTINGTREE_LEFT_OFFSET = 5;
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
1095 const int PatchesSelectionWindow::SETTINGTREE_TOP_OFFSET = 47;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1096
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097 static const Widget _patches_selection_widgets[] = {
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
1098 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1099 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_MAUVE, 11, 381, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1100 { WWT_PANEL, RESIZE_RIGHT, COLOUR_MAUVE, 0, 381, 14, 41, 0x0, STR_NULL},
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1101 { WWT_PANEL, RESIZE_RB, COLOUR_MAUVE, 0, 369, 42, 215, 0x0, STR_NULL}, // PATCHSEL_OPTIONSPANEL
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1102 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_MAUVE, 370, 381, 42, 203, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // PATCHSEL_SCROLLBAR
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1103 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 370, 381, 204, 215, 0x0, STR_RESIZE_BUTTON}, // PATCHSEL_RESIZE
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1104
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1105 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 100, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, // PATCHSEL_INTERFACE
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1106 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 101, 191, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, // PATCHSEL_CONSTRUCTION
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1107 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 192, 283, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, // PATCHSEL_VEHICLES
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1108 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 284, 375, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, // PATCHSEL_STATIONS
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1109 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 100, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, // PATCHSEL_ECONOMY
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1110 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 101, 191, 28, 39, STR_CONFIG_PATCHES_AI, STR_NULL}, // PATCHSEL_COMPETITORS
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1111 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1112 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1113
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1114 static const WindowDesc _patches_selection_desc = {
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1115 WDP_CENTER, WDP_CENTER, 382, 216, 382, 425,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
1116 WC_GAME_OPTIONS, WC_NONE,
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1117 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1118 _patches_selection_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1119 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1120
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
1121 void ShowPatchesSelection()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1122 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1123 DeleteWindowById(WC_GAME_OPTIONS, 0);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1124 new PatchesSelectionWindow(&_patches_selection_desc);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1125 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1126
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1127
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1128 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1129 * Draw [<][>] boxes.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1130 * @param x the x position to draw
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1131 * @param y the y position to draw
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1132 * @param button_colour the colour of the button
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1133 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1134 * @param clickable_left is the left button clickable?
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1135 * @param clickable_right is the right button clickable?
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1136 */
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1137 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1138 {
10358
531cadaa0bbc (svn r14609) -Codechange: Use supplied button colour instead of hardcoded yellow, for 'greyed out' arrow buttons. (Yorick)
peter1138 <peter1138@openttd.org>
parents: 10310
diff changeset
1139 int colour = _colour_gradient[button_colour][2];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1140
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1141 DrawFrameRect(x, y + 1, x + 9, y + 9, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1142 DrawFrameRect(x + 10, y + 1, x + 19, y + 9, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7742
diff changeset
1143 DrawStringCentered(x + 5, y + 1, STR_6819, TC_FROMSTRING); // [<]
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7742
diff changeset
1144 DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1145
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1146 /* Grey out the buttons that aren't clickable */
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1147 if (!clickable_left) {
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1148 GfxFillRect(x + 1, y + 1, x + 1 + 8, y + 8, colour, FILLRECT_CHECKER);
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1149 }
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1150 if (!clickable_right) {
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1151 GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, colour, FILLRECT_CHECKER);
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
1152 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1153 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1154
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1155 /** These are not, strickly speaking, widget enums,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1156 * since they have been changed as line coordinates.
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1157 * So, rather, they are more like order of appearance */
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1158 enum CustomCurrenciesWidgets {
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1159 CUSTCURR_EXCHANGERATE = 0,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1160 CUSTCURR_SEPARATOR,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1161 CUSTCURR_PREFIX,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1162 CUSTCURR_SUFFIX,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1163 CUSTCURR_TO_EURO,
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1164 };
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1165
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1166 struct CustomCurrencyWindow : Window {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1167 char separator[2];
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1168 int click;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1169 int query_widget;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1170
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1171 CustomCurrencyWindow(const WindowDesc *desc) : Window(desc)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1172 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1173 this->separator[0] = _custom_currency.separator;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1174 this->separator[1] = '\0';
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1175 this->FindWindowPlacementAndResize(desc);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1176 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1177
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1178 virtual void OnPaint()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1179 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1180 int x;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1181 int y = 20;
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9246
diff changeset
1182 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1183
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1184 /* exchange rate */
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1185 DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 0, 2), true, true);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1186 SetDParam(0, 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1187 SetDParam(1, 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1188 DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1189 y += 12;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1190
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1191 /* separator */
9770
9f72f4a2aee0 (svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents: 9764
diff changeset
1192 DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 2, 2) ? FR_LOWERED : FR_NONE);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1193 x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1194 DoDrawString(this->separator, x + 4, y + 1, TC_ORANGE);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1195 y += 12;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1196
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1197 /* prefix */
9770
9f72f4a2aee0 (svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents: 9764
diff changeset
1198 DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 4, 2) ? FR_LOWERED : FR_NONE);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1199 x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1200 DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1201 y += 12;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1202
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1203 /* suffix */
9770
9f72f4a2aee0 (svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents: 9764
diff changeset
1204 DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 6, 2) ? FR_LOWERED : FR_NONE);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1205 x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1206 DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1207 y += 12;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1208
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1209 /* switch to euro */
9871
fa16e41cec2c (svn r14017) -Codechange: DrawArrowButtons now uses Colours enum to specify the colour of the button
belugas <belugas@openttd.org>
parents: 9793
diff changeset
1210 DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 8, 2), true, true);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1211 SetDParam(0, _custom_currency.to_euro);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1212 DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1213 y += 12;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1214
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1215 /* Preview */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1216 y += 12;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1217 SetDParam(0, 10000);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1218 DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1219 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1220
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1221 virtual void OnClick(Point pt, int widget)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1222 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1223 int line = (pt.y - 20) / 12;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1224 int len = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1225 int x = pt.x;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1226 StringID str = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1227 CharSetFilter afilter = CS_ALPHANUMERAL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1228
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1229 switch (line) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1230 case CUSTCURR_EXCHANGERATE:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1231 if (IsInsideMM(x, 10, 30)) { // clicked buttons
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1232 if (x < 20) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1233 if (_custom_currency.rate > 1) _custom_currency.rate--;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1234 this->click = 1 << (line * 2 + 0);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1235 } else {
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1236 if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1237 this->click = 1 << (line * 2 + 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1238 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1239 } else { // enter text
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1240 SetDParam(0, _custom_currency.rate);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1241 str = STR_CONFIG_PATCHES_INT32;
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1242 len = 5;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1243 afilter = CS_NUMERAL;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1244 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1245 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1246
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1247 case CUSTCURR_SEPARATOR:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1248 if (IsInsideMM(x, 10, 30)) { // clicked button
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1249 this->click = 1 << (line * 2 + 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1250 }
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1251 SetDParamStr(0, this->separator);
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1252 str = STR_JUST_RAW_STRING;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1253 len = 1;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1254 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1255
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1256 case CUSTCURR_PREFIX:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1257 if (IsInsideMM(x, 10, 30)) { // clicked button
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1258 this->click = 1 << (line * 2 + 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1259 }
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1260 SetDParamStr(0, _custom_currency.prefix);
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1261 str = STR_JUST_RAW_STRING;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1262 len = 12;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1263 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1264
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1265 case CUSTCURR_SUFFIX:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1266 if (IsInsideMM(x, 10, 30)) { // clicked button
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1267 this->click = 1 << (line * 2 + 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1268 }
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1269 SetDParamStr(0, _custom_currency.suffix);
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9607
diff changeset
1270 str = STR_JUST_RAW_STRING;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1271 len = 12;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1272 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1273
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1274 case CUSTCURR_TO_EURO:
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1275 if (IsInsideMM(x, 10, 30)) { // clicked buttons
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1276 if (x < 20) {
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1277 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1278 this->click = 1 << (line * 2 + 0);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1279 } else {
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1280 _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1281 this->click = 1 << (line * 2 + 1);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1282 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1283 } else { // enter text
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1284 SetDParam(0, _custom_currency.to_euro);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1285 str = STR_CONFIG_PATCHES_INT32;
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1286 len = 7;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1287 afilter = CS_NUMERAL;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1288 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1289 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1290 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1291
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1292 if (len != 0) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1293 this->query_widget = line;
10145
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 9872
diff changeset
1294 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter, QSF_NONE);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1295 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1296
10180
e024f1d28082 (svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents: 10145
diff changeset
1297 this->flags4 |= WF_TIMEOUT_BEGIN;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1298 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1299 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1300
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1301 virtual void OnQueryTextFinished(char *str)
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1302 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1303 if (str == NULL) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1304
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1305 switch (this->query_widget) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1306 case CUSTCURR_EXCHANGERATE:
10510
c317167cc7a4 (svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
rubidium <rubidium@openttd.org>
parents: 10500
diff changeset
1307 _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1308 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1309
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1310 case CUSTCURR_SEPARATOR: /* Thousands seperator */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1311 _custom_currency.separator = StrEmpty(str) ? ' ' : str[0];
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10234
diff changeset
1312 strecpy(this->separator, str, lastof(this->separator));
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1313 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1314
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1315 case CUSTCURR_PREFIX:
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10234
diff changeset
1316 strecpy(_custom_currency.prefix, str, lastof(_custom_currency.prefix));
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1317 break;
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1318
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1319 case CUSTCURR_SUFFIX:
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10234
diff changeset
1320 strecpy(_custom_currency.suffix, str, lastof(_custom_currency.suffix));
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1321 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1322
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1323 case CUSTCURR_TO_EURO: { /* Year to switch to euro */
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1324 int val = atoi(str);
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1325
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1326 _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1327 break;
8188
2ca3ac32fa76 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas <belugas@openttd.org>
parents: 8182
diff changeset
1328 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1329 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1330 MarkWholeScreenDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1331 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1332
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1333 virtual void OnTimeout()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1334 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1335 this->click = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1336 this->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1337 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1338 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1339
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1340 static const Widget _cust_currency_widgets[] = {
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
1341 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
1342 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 229, 0, 13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9648
diff changeset
1343 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 229, 14, 119, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1344 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1345 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1346
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1347 static const WindowDesc _cust_currency_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7177
diff changeset
1348 WDP_CENTER, WDP_CENTER, 230, 120, 230, 120,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
1349 WC_CUSTOM_CURRENCY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1350 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1351 _cust_currency_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1352 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1353
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
1354 static void ShowCustCurrency()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1355 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1356 DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1357 new CustomCurrencyWindow(&_cust_currency_desc);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1358 }