Mercurial > hg > openttd
annotate src/settings_gui.cpp @ 10510:c317167cc7a4 draft
(svn r14767) -Codechange: remove some unneeded artificial limits from currencies and use the bounds of the data type.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 29 Dec 2008 15:46:14 +0000 |
parents | 543c3d2c5c42 |
children | d33755b6159a |
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" |
9581
9a3e1ee617ce
(svn r13618) -Codechange: move tar-specific declarations to separate file
smatz <smatz@openttd.org>
parents:
9533
diff
changeset
|
30 #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
|
31 |
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
|
32 #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
|
33 #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
|
34 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 }; |
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 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
|
43 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
|
44 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
|
45 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
|
46 }; |
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 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 }; |
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 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
|
58 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
|
59 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
|
60 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
|
61 }; |
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 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
|
64 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 *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
|
69 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
|
70 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
71 |
6956
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
72 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
|
73 static StringID *_grf_names = NULL; |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
74 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
|
75 |
8323
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
76 void InitGRFTownGeneratorNames() |
6797
d48143c8467b
(svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents:
6730
diff
changeset
|
77 { |
6956
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
78 free(_grf_names); |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
79 _grf_names = GetGRFTownNameList(); |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
80 _nb_grf_names = 0; |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
81 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
|
82 } |
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 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
|
85 { |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
86 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
|
87 town_name -= _nb_orig_names; |
6d300d04ac5e
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents:
6950
diff
changeset
|
88 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
|
89 return STR_UNDEFINED; |
6797
d48143c8467b
(svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents:
6730
diff
changeset
|
90 } |
d48143c8467b
(svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents:
6730
diff
changeset
|
91 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
92 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
|
93 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
94 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
|
95 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
96 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
|
97 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
|
98 _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
|
99 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
100 } |
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 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
|
103 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 |
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
|
105 enum GameOptionsWidgets { |
8336
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
106 GAMEOPT_CURRENCY_BTN = 4, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
107 GAMEOPT_DISTANCE_BTN = 6, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
108 GAMEOPT_ROADSIDE_BTN = 8, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
109 GAMEOPT_TOWNNAME_BTN = 10, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
110 GAMEOPT_AUTOSAVE_BTN = 12, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
111 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
|
112 GAMEOPT_VEHICLENAME_SAVE, |
8336
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
113 GAMEOPT_LANG_BTN = 17, |
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
114 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
|
115 GAMEOPT_FULLSCREEN, |
8336
4f73dcb0e148
(svn r11902) -Codechange: use new dropdown widget for game options window
peter1138 <peter1138@openttd.org>
parents:
8323
diff
changeset
|
116 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
|
117 }; |
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 |
8321
c361d51b1bb8
(svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents:
8319
diff
changeset
|
119 /** |
8323
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
120 * 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
|
121 * @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
|
122 * @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
|
123 */ |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
124 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
|
125 { |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
126 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
|
127 TownList townnames; |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
128 |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
129 /* 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
|
130 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
|
131 |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
132 /* 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
|
133 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
|
134 |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
135 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
|
136 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
|
137 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
|
138 } |
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 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
|
141 } |
803ed468fc77
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents:
8321
diff
changeset
|
142 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
143 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
|
144 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
145 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
|
146 GameSettings *opt; |
9346
0c181c088ed8
(svn r13242) -Codechange: remove _opt_ptr.
rubidium <rubidium@openttd.org>
parents:
9334
diff
changeset
|
147 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
148 GameOptionsWindow(const WindowDesc *desc) : Window(desc) |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
149 { |
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
|
150 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
|
151 this->FindWindowPlacementAndResize(desc); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
152 } |
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
|
153 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
154 ~GameOptionsWindow() |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
155 { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
156 DeleteWindowById(WC_CUSTOM_CURRENCY, 0); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
157 } |
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
|
158 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
159 virtual void OnPaint() |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
160 { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
161 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
|
162 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 int i = GetCurRes(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
177 this->DrawWidgets(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
178 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
|
179 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
180 |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
181 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
|
182 { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
183 switch (widget) { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
184 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
|
185 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
|
186 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
187 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
188 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
|
189 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
|
190 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
191 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
192 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
|
193 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
|
194 extern bool RoadVehiclesAreBuilt(); |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
195 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
196 /* 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
|
197 * 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
|
198 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
|
199 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
|
200 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
201 |
9358
12f4585b2124
(svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
202 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
|
203 } break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
204 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
205 case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown |
9358
12f4585b2124
(svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
206 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
|
207 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
208 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
209 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
|
210 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
|
211 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
212 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
213 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
|
214 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
|
215 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
216 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
217 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
|
218 break; // not implemented |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
219 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
220 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
|
221 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
|
222 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
223 /* Sort language names */ |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
224 LangList langs; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
225 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
|
226 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
227 DropDownList *list = new DropDownList(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
228 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
|
229 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
|
230 } |
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 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
|
233 } break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
234 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
235 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
|
236 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
|
237 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
238 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
239 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
|
240 /* 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
|
241 if (!ToggleFullScreen(!_fullscreen)) { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
242 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
|
243 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
244 this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
245 this->SetDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
246 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
247 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
248 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
|
249 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
|
250 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
251 } |
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 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
|
255 { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
256 switch (widget) { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
257 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
|
258 if (index == 0) { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
259 DeleteCustomEngineNames(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
260 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
261 } else if (!(_vehicle_design_names & 1)) { |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
262 LoadCustomEngineNames(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
263 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
264 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
265 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
266 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
267 case GAMEOPT_CURRENCY_BTN: /* Currency */ |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
268 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
|
269 this->opt->locale.currency = index; |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
270 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
271 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
272 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
273 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
|
274 this->opt->locale.units = index; |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
275 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
276 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
277 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
278 case GAMEOPT_ROADSIDE_BTN: // Road side |
9358
12f4585b2124
(svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
279 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
|
280 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
|
281 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
282 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
283 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
284 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
285 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
|
286 if (_game_mode == GM_MENU || GetNumTowns() == 0) { |
9358
12f4585b2124
(svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
287 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
|
288 InvalidateWindow(WC_GAME_OPTIONS, 0); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
289 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
290 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
291 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
292 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
|
293 _settings_client.gui.autosave = index; |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
294 this->SetDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
295 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
296 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
297 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
|
298 ReadLanguagePack(index); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
299 CheckForMissingGlyphsInLoadedLanguagePack(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
300 UpdateAllStationVirtCoord(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
301 UpdateAllWaypointSigns(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
302 MarkWholeScreenDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
303 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
304 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
305 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
|
306 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
|
307 this->SetDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
308 } |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
309 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
310 |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
311 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
|
312 SetScreenshotFormat(index); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
313 this->SetDirty(); |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
314 break; |
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
315 } |
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 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 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
|
320 { 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
|
321 { 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
|
322 { 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
|
323 { 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
|
324 { 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
|
325 { 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
|
326 { 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
|
327 { 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
|
328 { 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
|
329 { 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
|
330 { 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
|
331 { 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
|
332 { 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
|
333 |
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
|
334 { 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
|
335 { 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
|
336 { 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
|
337 |
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
|
338 { 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
|
339 { 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
|
340 |
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
|
341 { 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
|
342 { 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
|
343 { 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
|
344 |
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
|
345 { 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
|
346 { 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
|
347 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 { 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
|
349 }; |
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 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
|
352 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
|
353 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
|
354 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
|
355 _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
|
356 }; |
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 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
359 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
|
360 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
361 DeleteWindowById(WC_GAME_OPTIONS, 0); |
9291
f9b184a11fea
(svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
362 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
|
363 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
364 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
365 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
|
366 |
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
|
367 /* 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
|
368 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
|
369 { 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
|
370 { 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
|
371 { 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
|
372 { 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
|
373 { 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
|
374 { 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
|
375 { 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
|
376 { 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
|
377 { 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
|
378 { 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
|
379 { 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
|
380 { 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
|
381 { 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
|
382 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 |
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
|
384 /* 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 _game_difficulty_widgets, |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
390 }; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
391 |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
392 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
|
393 |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
394 struct GameDifficultyWindow : public Window { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
395 private: |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
396 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
|
397 bool clicked_increase; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
398 uint8 clicked_button; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
399 uint8 timeout; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
400 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
401 /* 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
|
402 GameSettings opt_mod_temp; |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
403 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
404 enum { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
405 GAMEDIFF_WND_TOP_OFFSET = 45, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
406 GAMEDIFF_WND_ROWSIZE = 9, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
407 NO_SETTINGS_BUTTON = 0xFF, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
408 }; |
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 /* 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
|
411 enum GameDifficultyWidgets { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
412 GDW_CLOSEBOX = 0, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
413 GDW_CAPTION, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
414 GDW_UPPER_BG, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
415 GDW_LVL_EASY, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
416 GDW_LVL_MEDIUM, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
417 GDW_LVL_HARD, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
418 GDW_LVL_CUSTOM, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
419 GDW_HIGHSCORE, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
420 GDW_SETTING_BG, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
421 GDW_LOWER_BG, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
422 GDW_ACCEPT, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
423 GDW_CANCEL, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
424 }; |
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 public: |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
427 GameDifficultyWindow() : Window(&_game_difficulty_desc) |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
428 { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
429 /* 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
|
430 * 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
|
431 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
|
432 this->clicked_increase = false; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
433 this->clicked_button = NO_SETTINGS_BUTTON; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
434 this->timeout = 0; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
435 /* 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
|
436 this->HideWidget(GDW_CLOSEBOX); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
437 this->widget[GDW_CAPTION].left = 0; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
438 /* Setup disabled buttons when creating window |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
439 * 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
|
440 this->SetWidgetsDisabledState(_game_mode == GM_NORMAL, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
441 GDW_LVL_EASY, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
442 GDW_LVL_MEDIUM, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
443 GDW_LVL_HARD, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
444 GDW_LVL_CUSTOM, |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
445 WIDGET_LIST_END); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 this->FindWindowPlacementAndResize(&_game_difficulty_desc); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
450 } |
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 virtual void OnPaint() |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
453 { |
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
|
454 this->DrawWidgets(); |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
455 |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
456 uint i; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
457 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
|
458 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
|
459 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
|
460 const SettingDescBase *sdb = &sd->desc; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
461 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
|
462 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
|
463 |
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
|
464 DrawArrowButtons(5, y, COLOUR_YELLOW, |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
465 (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
|
466 editable && sdb->min != value, |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
467 editable && sdb->max != value); |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
468 |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
469 value += sdb->str; |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
470 SetDParam(0, value); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
471 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
|
472 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
473 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
|
474 } |
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 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
|
478 { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
479 switch (widget) { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
480 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
|
481 /* 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
|
482 if (_networking && !_network_server) return; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
483 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
484 const int x = pt.x - 5; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
485 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
|
486 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
487 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
|
488 if (y < 0) return; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
489 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
490 /* Get button from Y coord. */ |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
491 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
|
492 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
|
493 |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
494 uint i; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
495 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
|
496 const SettingDescBase *sdb = &sd->desc; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
497 |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
498 /* Clicked disabled button? */ |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
499 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
|
500 if (!editable) return; |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
501 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
502 this->timeout = 5; |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
503 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
|
504 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
505 if (x >= 10) { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
506 /* Increase button clicked */ |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
507 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
|
508 this->clicked_increase = true; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
509 } else { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
510 /* Decrease button clicked */ |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
511 val -= sdb->interval; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
512 val = max(val, sdb->min); |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
513 this->clicked_increase = false; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
514 } |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
515 this->clicked_button = btn; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
516 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
517 /* save value in temporary variable */ |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
518 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
|
519 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
|
520 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
|
521 this->LowerWidget(GDW_LVL_CUSTOM); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
522 this->SetDirty(); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
523 } break; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
524 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
525 case GDW_LVL_EASY: |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
526 case GDW_LVL_MEDIUM: |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
527 case GDW_LVL_HARD: |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
528 case GDW_LVL_CUSTOM: |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
529 /* temporarily change difficulty level */ |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
530 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
|
531 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
|
532 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
|
533 this->SetDirty(); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
534 break; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
535 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
536 case GDW_HIGHSCORE: // Highscore Table |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
537 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
|
538 break; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
539 |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
540 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
|
541 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
|
542 |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
543 uint i; |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
544 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
|
545 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
|
546 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
|
547 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
|
548 /* 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
|
549 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
|
550 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
|
551 } |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
552 } |
9359
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
553 |
c3a0ec3104c9
(svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
554 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
|
555 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
|
556 delete this; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
557 /* 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
|
558 * 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
|
559 * are loaded correctly. */ |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
560 if (_game_mode == GM_EDITOR) StartupEconomy(); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
561 break; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
562 } |
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 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
|
565 delete this; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
566 break; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
567 } |
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 virtual void OnTick() |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
571 { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
572 if (this->timeout != 0) { |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
573 this->timeout--; |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
574 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
|
575 this->SetDirty(); |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
576 } |
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
577 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
580 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
|
581 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 DeleteWindowById(WC_GAME_OPTIONS, 0); |
9231
6ddeba445c3a
(svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents:
9164
diff
changeset
|
583 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
|
584 } |
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 static const char *_patches_ui[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
587 "gui.vehicle_speed", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
588 "gui.status_long_date", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
589 "gui.show_finances", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
590 "gui.autoscroll", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
591 "gui.reverse_scroll", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
592 "gui.smooth_scroll", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
593 "gui.errmsg_duration", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
594 "gui.toolbar_pos", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
595 "gui.measure_tooltip", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
596 "gui.window_snap_radius", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
597 "gui.population_in_label", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
598 "gui.link_terraform_toolbar", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
599 "gui.liveries", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
600 "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
|
601 /* 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
|
602 * 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
|
603 * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */ |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
604 "gui.scrollwheel_scrolling", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
605 "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
|
606 #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
|
607 /* We might need to emulate a right mouse button on mac */ |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
608 "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
|
609 #endif |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
610 "gui.pause_on_newgame", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
611 "gui.advanced_vehicle_list", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
612 "gui.loading_indicators", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
613 "gui.timetable_in_ticks", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
614 "gui.default_rail_type", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
615 "gui.always_build_infrastructure", |
9785
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9770
diff
changeset
|
616 "gui.show_track_reservation", |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
618 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
619 static const char *_patches_construction[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
620 "construction.build_on_slopes", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
621 "construction.autoslope", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
622 "construction.extra_dynamite", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
623 "construction.longbridges", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
624 "construction.signal_side", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
625 "station.always_small_airport", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
626 "gui.enable_signal_gui", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
627 "gui.drag_signals_density", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
628 "game_creation.oil_refinery_limit", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
629 "gui.semaphore_build_before", |
9793
7a1f095154a8
(svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
630 "gui.default_signal_type", |
7a1f095154a8
(svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
631 "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
|
632 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
634 static const char *_patches_stations[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
635 "station.join_stations", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
636 "order.improved_load", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
637 "order.selectgoods", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
638 "gui.new_nonstop", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
639 "station.nonuniform_stations", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
640 "station.station_spread", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
641 "order.serviceathelipad", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
642 "station.modified_catchment", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
643 "order.gradual_loading", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
644 "construction.road_stop_on_town_road", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
645 "station.adjacent_stations", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
646 "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
|
647 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
648 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 static const char *_patches_economy[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
650 "economy.inflation", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
651 "construction.raw_industry_construction", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
652 "economy.multiple_industry_per_town", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
653 "economy.same_industry_close", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
654 "economy.bribe", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
655 "economy.exclusive_rights", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
656 "economy.give_money", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
657 "gui.colored_news_year", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
658 "economy.smooth_economy", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
659 "economy.allow_shares", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
660 "economy.town_layout", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
661 "economy.mod_road_rebuild", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
662 "economy.town_growth_rate", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
663 "economy.larger_towns", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
664 "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
|
665 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
666 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
667 static const char *_patches_ai[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
668 "ai.ainew_active", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
669 "ai.ai_in_multiplayer", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
670 "ai.ai_disable_veh_train", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
671 "ai.ai_disable_veh_roadveh", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
672 "ai.ai_disable_veh_aircraft", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
673 "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
|
674 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 static const char *_patches_vehicles[] = { |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
677 "vehicle.realistic_acceleration", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
678 "pf.forbid_90_deg", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
679 "vehicle.mammoth_trains", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
680 "order.gotodepot", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
681 "pf.roadveh_queue", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
682 "pf.pathfinder_for_trains", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
683 "pf.pathfinder_for_roadvehs", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
684 "pf.pathfinder_for_ships", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
685 "gui.train_income_warn", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
686 "gui.order_review_system", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
687 "vehicle.never_expire_vehicles", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
688 "gui.lost_train_warn", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
689 "gui.autorenew", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
690 "gui.autorenew_months", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
691 "gui.autorenew_money", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
692 "vehicle.max_trains", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
693 "vehicle.max_roadveh", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
694 "vehicle.max_aircraft", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
695 "vehicle.max_ships", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
696 "vehicle.servint_ispercent", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
697 "vehicle.servint_trains", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
698 "vehicle.servint_roadveh", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
699 "vehicle.servint_ships", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
700 "vehicle.servint_aircraft", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
701 "order.no_servicing_if_no_breakdowns", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
702 "vehicle.wagon_speed_limits", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
703 "vehicle.disable_elrails", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
704 "vehicle.freight_trains", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
705 "vehicle.plane_speed", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
706 "order.timetabling", |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
707 "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
|
708 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
709 |
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
|
710 /** Data structure describing a single patch in a tab */ |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
711 struct PatchEntry { |
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
|
712 const SettingDesc *setting; ///< Setting description of the patch |
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
|
713 uint index; ///< Index of the setting in the settings table |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
714 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 |
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
|
716 /** |
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
|
717 * Data structure describing one page of patches in the patch settings window. |
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
|
718 * |
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
|
719 * The names of the patches to display are statically defined, and from this |
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
|
720 * information, a dynamic array (with length \a num) of PatchEntry entries is |
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
|
721 * constructed. |
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
|
722 */ |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
723 struct PatchPage { |
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
|
724 const char **names; ///< Static list of strings with patch names that are settable from the tab |
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
|
725 PatchEntry *entries; ///< Array of patch entries of the page. Initially \c NULL, filled in at run time |
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
|
726 byte num; ///< Number of entries on the page (statically filled). |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
727 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
728 |
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
|
729 /** 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
|
730 static PatchPage _patches_page[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
731 {_patches_ui, NULL, lengthof(_patches_ui)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 {_patches_construction, NULL, lengthof(_patches_construction)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 {_patches_vehicles, NULL, lengthof(_patches_vehicles)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
734 {_patches_stations, NULL, lengthof(_patches_stations)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
735 {_patches_economy, NULL, lengthof(_patches_economy)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
736 {_patches_ai, NULL, lengthof(_patches_ai)}, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
737 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
738 |
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
|
739 /** 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
|
740 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
|
741 PATCHSEL_OPTIONSPANEL = 3, ///< Panel widget containing the option lists |
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
|
742 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
|
743 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
|
744 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
|
745 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
|
746 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
|
747 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
|
748 }; |
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
|
749 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
750 struct PatchesSelectionWindow : 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
|
751 static GameSettings *patches_ptr; |
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
|
752 static int patches_max; ///< Maximal number of patches on a single page |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
753 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
754 int page; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
755 int entry; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
756 int click; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
757 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
758 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
|
759 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
760 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
|
761 |
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
|
762 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
|
763 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
764 /* 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
|
765 if (first_time) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
766 PatchPage *page; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
767 for (page = &_patches_page[0]; page != endof(_patches_page); page++) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
768 uint i; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
769 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
770 if (patches_max < page->num) patches_max = page->num; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
771 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
772 page->entries = MallocT<PatchEntry>(page->num); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
773 for (i = 0; i != page->num; i++) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
774 uint index; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
775 const SettingDesc *sd = GetPatchFromName(page->names[i], &index); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
776 assert(sd != 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
|
777 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
778 page->entries[i].setting = sd; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
779 page->entries[i].index = index; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
780 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
781 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
782 first_time = false; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
783 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
784 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
785 /* Resize the window to fit the largest patch tab */ |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
786 ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
787 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
788 /* Recentre the window for the new size */ |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
789 this->top = this->top - (patches_max * 11) / 2; |
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
|
790 |
10234
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
791 this->LowerWidget(PATCHSEL_INTERFACE); |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
792 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
793 this->FindWindowPlacementAndResize(desc); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
794 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
795 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
796 virtual void OnPaint() |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
797 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
798 int x, y; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
799 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
|
800 uint i; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
801 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
802 /* 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
|
803 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
|
804 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
805 x = 5; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
806 y = 47; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
807 for (i = 0; i != page->num; i++) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
808 const SettingDesc *sd = page->entries[i].setting; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
809 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
|
810 const void *var = GetVariableAddress(patches_ptr, &sd->save); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
811 bool editable = true; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
812 bool disabled = false; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
813 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
814 // We do not allow changes of some items when we are a client in a networkgame |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
815 if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
816 if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
817 if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false; |
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
|
818 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
819 if (sdb->cmd == SDT_BOOLX) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
820 static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}}; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
821 /* Draw checkbox for boolean-value either on/off */ |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
822 bool on = (*(bool*)var); |
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
|
823 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
824 DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
825 SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
826 } else { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
827 int32 value; |
8594
2ed0f71a87ff
(svn r12175) -Fix (r12174): Ensure the patches window is centred properly.
peter1138 <peter1138@openttd.org>
parents:
8593
diff
changeset
|
828 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
829 value = (int32)ReadValue(var, sd->save.conv); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
830 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
831 /* Draw [<][>] boxes for settings of an integer-type */ |
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
|
832 DrawArrowButtons(x, y, COLOUR_YELLOW, this->click - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); |
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 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
834 disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
835 if (disabled) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
836 SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
837 } else { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
838 if (sdb->flags & SGF_CURRENCY) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
839 SetDParam(0, STR_CONFIG_PATCHES_CURRENCY); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
840 } else if (sdb->flags & SGF_MULTISTRING) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
841 SetDParam(0, sdb->str + value + 1); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
842 } else { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
843 SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
844 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
845 SetDParam(1, value); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
846 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
847 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
848 DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
849 y += 11; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
850 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
851 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
852 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
853 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
|
854 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
855 switch (widget) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
856 case PATCHSEL_OPTIONSPANEL: { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
857 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
|
858 const SettingDesc *sd; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
859 void *var; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
860 int32 value; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
861 int x, y; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
862 byte btn; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
863 |
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
|
864 y = pt.y - 46 - 1; // Shift y coordinate |
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
|
865 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
|
866 |
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
|
867 x = pt.x - 5; // Shift x coordinate |
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
|
868 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
|
869 |
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
|
870 btn = y / 11; // Compute which setting is selected |
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
|
871 if (y % 11 > 9) return; // Clicked too low at the setting |
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
|
872 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
|
873 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
874 sd = page->entries[btn].setting; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
875 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
876 /* 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
|
877 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
|
878 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
|
879 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
|
880 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
881 var = GetVariableAddress(patches_ptr, &sd->save); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
882 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
|
883 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
884 /* 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
|
885 if (x < 21) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
886 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
|
887 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
|
888 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
889 switch (sdb->cmd) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
890 case SDT_BOOLX: value ^= 1; break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
891 case SDT_NUMX: { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
892 /* 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
|
893 * 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
|
894 * 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
|
895 * 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
|
896 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
|
897 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
|
898 |
10180
e024f1d28082
(svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
899 /* don't allow too fast scrolling */ |
e024f1d28082
(svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
900 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
|
901 _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
|
902 return; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
903 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
905 /* 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
|
906 if (x >= 10) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
907 value += step; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
908 if (value > sdb->max) value = sdb->max; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
909 } else { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
910 value -= step; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
911 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
|
912 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
913 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
914 /* 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
|
915 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
|
916 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
|
917 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
|
918 _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
|
919 } |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
920 } break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
921 default: NOT_REACHED(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
922 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
923 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
924 if (value != oldvalue) { |
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
|
925 SetPatchValue(page->entries[btn].index, value); |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
926 this->SetDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
927 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
928 } else { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
929 /* 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
|
930 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
|
931 /* 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
|
932 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
|
933 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
934 this->entry = btn; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
935 SetDParam(0, value); |
10145
dbe302da93a8
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents:
9872
diff
changeset
|
936 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
|
937 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
938 } |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
939 } 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
|
940 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
941 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
|
942 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
|
943 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
|
944 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
|
945 this->LowerWidget(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
|
946 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
|
947 this->SetDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
948 break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
949 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
950 } |
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
|
951 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
952 virtual void OnTimeout() |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
953 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
954 this->click = 0; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
955 this->SetDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
956 } |
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
|
957 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
958 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
|
959 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
960 if (!StrEmpty(str)) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
961 const PatchEntry *pe = &_patches_page[this->page].entries[this->entry]; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
962 const SettingDesc *sd = pe->setting; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
963 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
|
964 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
965 /* 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
|
966 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
|
967 |
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
|
968 SetPatchValue(pe->index, value); |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
969 this->SetDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
970 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
971 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
972 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 |
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
|
974 GameSettings *PatchesSelectionWindow::patches_ptr = NULL; |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
975 int PatchesSelectionWindow::patches_max = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
976 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
977 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
|
978 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 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
|
979 { WWT_CAPTION, RESIZE_NONE, COLOUR_MAUVE, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, 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
|
980 { WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 14, 41, 0x0, STR_NULL}, |
10234
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
981 { WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 42, 50, 0x0, STR_NULL}, // PATCHSEL_OPTIONSPANEL |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
982 |
10234
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
983 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, // PATCHSEL_INTERFACE |
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
984 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, // PATCHSEL_CONSTRUCTION |
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
985 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, // PATCHSEL_VEHICLES |
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
986 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, // PATCHSEL_STATIONS |
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
987 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, // PATCHSEL_ECONOMY |
5295dda5f4e9
(svn r14462) -Codechange: replace magic number with already existing constant (Albert)
rubidium <rubidium@openttd.org>
parents:
10199
diff
changeset
|
988 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 97, 183, 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
|
989 { 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
|
990 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
991 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
992 static const WindowDesc _patches_selection_desc = { |
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
|
993 WDP_CENTER, WDP_CENTER, 370, 51, 370, 51, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5688
diff
changeset
|
994 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
|
995 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
|
996 _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
|
997 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
998 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
999 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
|
1000 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1001 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
|
1002 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
|
1003 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1004 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1005 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1006 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1007 * 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
|
1008 * @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
|
1009 * @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
|
1010 * @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
|
1011 * @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
|
1012 * @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
|
1013 * @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
|
1014 */ |
9872
c26adcd5367e
(svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents:
9871
diff
changeset
|
1015 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
|
1016 { |
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
|
1017 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
|
1018 |
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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 /* 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
|
1025 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
|
1026 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
|
1027 } |
c26adcd5367e
(svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents:
9871
diff
changeset
|
1028 if (!clickable_right) { |
c26adcd5367e
(svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents:
9871
diff
changeset
|
1029 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
|
1030 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1031 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1032 |
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
|
1033 /** 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
|
1034 * 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
|
1035 * 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 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
|
1042 }; |
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
|
1043 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1044 struct CustomCurrencyWindow : Window { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1045 char separator[2]; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1046 int click; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1047 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
|
1048 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1049 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
|
1050 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1051 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
|
1052 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
|
1053 this->FindWindowPlacementAndResize(desc); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1054 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1055 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1056 virtual void OnPaint() |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1057 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1058 int x; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1059 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
|
1060 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
|
1061 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1062 /* 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
|
1063 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
|
1064 SetDParam(0, 1); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1065 SetDParam(1, 1); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1066 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
|
1067 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
|
1068 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1069 /* separator */ |
9770
9f72f4a2aee0
(svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents:
9764
diff
changeset
|
1070 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
|
1071 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
|
1072 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
|
1073 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
|
1074 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1075 /* prefix */ |
9770
9f72f4a2aee0
(svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents:
9764
diff
changeset
|
1076 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
|
1077 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
|
1078 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
|
1079 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
|
1080 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1081 /* suffix */ |
9770
9f72f4a2aee0
(svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents:
9764
diff
changeset
|
1082 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
|
1083 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
|
1084 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
|
1085 y += 12; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1086 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1087 /* 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
|
1088 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
|
1089 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
|
1090 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
|
1091 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
|
1092 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1093 /* Preview */ |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1094 y += 12; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1095 SetDParam(0, 10000); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1096 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
|
1097 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1098 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1099 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
|
1100 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1101 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
|
1102 int len = 0; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1103 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
|
1104 StringID str = 0; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1105 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
|
1106 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1107 switch (line) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1108 case CUSTCURR_EXCHANGERATE: |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1109 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
|
1110 if (x < 20) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1111 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
|
1112 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
|
1113 } 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
|
1114 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
|
1115 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
|
1116 } |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1117 } else { // enter text |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1118 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
|
1119 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
|
1120 len = 5; |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1121 afilter = CS_NUMERAL; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1122 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1123 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
|
1124 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1125 case CUSTCURR_SEPARATOR: |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1126 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
|
1127 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
|
1128 } |
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
|
1129 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
|
1130 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
|
1131 len = 1; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1132 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
|
1133 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1134 case CUSTCURR_PREFIX: |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1135 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
|
1136 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
|
1137 } |
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
|
1138 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
|
1139 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
|
1140 len = 12; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1141 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
|
1142 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1143 case CUSTCURR_SUFFIX: |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1144 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
|
1145 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
|
1146 } |
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
|
1147 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
|
1148 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
|
1149 len = 12; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1150 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
|
1151 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1152 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
|
1153 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
|
1154 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
|
1155 _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
|
1156 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
|
1157 } 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
|
1158 _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
|
1159 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
|
1160 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1161 } else { // enter text |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1162 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
|
1163 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
|
1164 len = 7; |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1165 afilter = CS_NUMERAL; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1166 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1167 break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1168 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1169 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1170 if (len != 0) { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1171 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
|
1172 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
|
1173 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 |
10180
e024f1d28082
(svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
1175 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
|
1176 this->SetDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1177 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1179 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
|
1180 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1181 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
|
1182 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1183 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
|
1184 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
|
1185 _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
|
1186 break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1187 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1188 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
|
1189 _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
|
1190 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
|
1191 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
|
1192 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1193 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
|
1194 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
|
1195 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
|
1196 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1197 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
|
1198 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
|
1199 break; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1200 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1201 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
|
1202 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
|
1203 |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1204 _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
|
1205 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
|
1206 } |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1207 } |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1208 MarkWholeScreenDirty(); |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1209 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1210 |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1211 virtual void OnTimeout() |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1212 { |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1213 this->click = 0; |
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1214 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
|
1215 } |
9246
1684bf12f0e0
(svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents:
9231
diff
changeset
|
1216 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1217 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1218 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
|
1219 { 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
|
1220 { 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
|
1221 { 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
|
1222 { 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
|
1223 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1224 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 _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
|
1230 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6012
diff
changeset
|
1232 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
|
1233 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 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
|
1235 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
|
1236 } |