annotate src/settings_gui.cpp @ 19718:bb4e1d9b4da9 draft

(svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
author yexo <yexo@openttd.org>
date Mon, 29 Oct 2012 19:53:13 +0000 (2012-10-29)
parents e1b57eff3699
children 22772cc2aaa2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12771
diff changeset
9
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
10 /** @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
11
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #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
13 #include "currency.h"
18627
1972f6346144 (svn r23474) -Codechange: move the declaration error related functions to error.h
rubidium <rubidium@openttd.org>
parents: 18570
diff changeset
14 #include "error.h"
19406
0731e1a0613a (svn r24309) -Codechange: Split some functions from gui.h to settings_gui.h
frosch <frosch@openttd.org>
parents: 19397
diff changeset
15 #include "settings_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
16 #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
17 #include "command_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
18 #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
19 #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
20 #include "town.h"
8208
ddc34919158f (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents: 8191
diff changeset
21 #include "settings_internal.h"
6956
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
22 #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
23 #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
24 #include "window_func.h"
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
25 #include "string_func.h"
8321
c361d51b1bb8 (svn r11886) -Add: sort the strings in languages dropdown
glx <glx@openttd.org>
parents: 8319
diff changeset
26 #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
27 #include "widgets/dropdown_func.h"
10558
15517829eb17 (svn r14815) -Codechange: separate 'highscore' code from 'company' code
smatz <smatz@openttd.org>
parents: 10543
diff changeset
28 #include "highscore.h"
12678
ea203bb44a25 (svn r17133) -Codechange: generalise the code that searches for base graphics
rubidium <rubidium@openttd.org>
parents: 12676
diff changeset
29 #include "base_media_base.h"
12022
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
30 #include "company_base.h"
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
31 #include "company_func.h"
13950
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13834
diff changeset
32 #include "viewport_func.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 14155
diff changeset
33 #include "core/geometry_func.hpp"
14330
9caa7d57a6e3 (svn r18883) -Codechange: warn in the difficulty and AI configuration window when setting the number of AIs to non-zero when you don't have AIs
rubidium <rubidium@openttd.org>
parents: 14258
diff changeset
34 #include "ai/ai.hpp"
18925
367a6d3cc642 (svn r23775) -Change: Hide the PCX screenshot format from the options window, if a 32bpp blitter is used.
frosch <frosch@openttd.org>
parents: 18908
diff changeset
35 #include "blitter/factory.hpp"
16445
c7c3bb467609 (svn r21161) -Codechange: make the currently used language easier accessible
rubidium <rubidium@openttd.org>
parents: 16441
diff changeset
36 #include "language.h"
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
37 #include "textfile_gui.h"
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
38 #include "stringfilter_type.h"
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
39 #include "querystring_gui.h"
18680
e87c7c30e606 (svn r23528) -Codechange: move widget enums to widgets/NNN_type.h
truebrain <truebrain@openttd.org>
parents: 18677
diff changeset
40
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
41
5584
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 _units_dropdown[] = {
12619
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12520
diff changeset
43 STR_GAME_OPTIONS_MEASURING_UNITS_IMPERIAL,
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12520
diff changeset
44 STR_GAME_OPTIONS_MEASURING_UNITS_METRIC,
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12520
diff changeset
45 STR_GAME_OPTIONS_MEASURING_UNITS_SI,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 static const StringID _driveside_dropdown[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
50 STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
51 STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_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
52 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
53 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55 static const StringID _autosave_dropdown[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
56 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
57 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
58 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
59 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11697
diff changeset
60 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 INVALID_STRING_ID,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
64 int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of original town names.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
65 static StringID *_grf_names = NULL; ///< Pointer to town names defined by NewGRFs.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
66 static int _nb_grf_names = 0; ///< Number of town names defined by NewGRFs.
6797
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
67
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
68 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
69
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
70 /** Allocate memory for the NewGRF town names. */
8323
803ed468fc77 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx <glx@openttd.org>
parents: 8321
diff changeset
71 void InitGRFTownGeneratorNames()
6797
d48143c8467b (svn r10036) -Add: sort the strings in town names dropdown
glx <glx@openttd.org>
parents: 6730
diff changeset
72 {
6956
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
73 free(_grf_names);
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
74 _grf_names = GetGRFTownNameList();
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
75 _nb_grf_names = 0;
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
76 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
77 }
6d300d04ac5e (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx <glx@openttd.org>
parents: 6950
diff changeset
78
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
79 /**
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
80 * Get a town name.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
81 * @param town_name Number of the wanted town name.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
82 * @return Name of the town as string ID.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
83 */
6956
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 {
12619
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12520
diff changeset
86 if (town_name < _nb_orig_names) return STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + town_name;
6956
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
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
92 /**
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
93 * Get index of the current screen resolution.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
94 * @return Index of the current screen resolution if it is a known resolution, #_num_resolutions otherwise.
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
95 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
96 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
97 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
98 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
99
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 for (i = 0; i != _num_resolutions; i++) {
12262
fd3b92f848cc (svn r16677) -Codechange: Dimension width and height are unsigned.
alberth <alberth@openttd.org>
parents: 12200
diff changeset
101 if ((int)_resolutions[i].width == _screen.width &&
fd3b92f848cc (svn r16677) -Codechange: Dimension width and height are unsigned.
alberth <alberth@openttd.org>
parents: 12200
diff changeset
102 (int)_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
103 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106 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
107 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
109 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
110
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
111 template <class T>
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
112 static DropDownList *BuiltSetDropDownList(int *selected_index)
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
113 {
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
114 int n = T::GetNumSets();
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
115 *selected_index = T::GetIndexOfUsedSet();
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
116
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
117 DropDownList *list = new DropDownList();
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
118 for (int i = 0; i < n; i++) {
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
119 list->push_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, (_game_mode == GM_MENU) ? false : (*selected_index != i)));
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
120 }
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
121
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
122 return list;
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
123 }
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
124
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
125 /** Window for displaying the textfile of a BaseSet. */
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
126 template <class TBaseSet>
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
127 struct BaseSetTextfileWindow : public TextfileWindow {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
128 const TBaseSet* baseset; ///< View the textfile of this BaseSet.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
129 StringID content_type; ///< STR_CONTENT_TYPE_xxx for title.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
130
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
131 BaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type) : TextfileWindow(file_type), baseset(baseset), content_type(content_type)
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
132 {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
133 const char *textfile = this->baseset->GetTextfile(file_type);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
134 this->LoadTextfile(textfile, BASESET_DIR);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
135 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
136
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
137 /* virtual */ void SetStringParameters(int widget) const
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
138 {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
139 if (widget == WID_TF_CAPTION) {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
140 SetDParam(0, content_type);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
141 SetDParamStr(1, this->baseset->name);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
142 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
143 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
144 };
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
145
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
146 /**
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
147 * Open the BaseSet version of the textfile window.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
148 * @param file_type The type of textfile to display.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
149 * @param baseset The BaseSet to use.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
150 * @param content_type STR_CONTENT_TYPE_xxx for title.
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
151 */
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
152 template <class TBaseSet>
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
153 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
154 {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
155 DeleteWindowByClass(WC_TEXTFILE);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
156 new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
157 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
158
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
159 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
160 GameSettings *opt;
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
161 bool reload;
9346
0c181c088ed8 (svn r13242) -Codechange: remove _opt_ptr.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
162
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
163 GameOptionsWindow(const WindowDesc *desc) : Window()
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
164 {
16959
55b2bec60c52 (svn r21695) -Codechange: add helper function to get the currently applicable GameSettings object
yexo <yexo@openttd.org>
parents: 16945
diff changeset
165 this->opt = &GetGameSettings();
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
166 this->reload = false;
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
167
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
168 this->InitNested(desc, WN_GAME_OPTIONS_GAME_OPTIONS);
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
169 this->OnInvalidateData(0);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
170 }
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
171
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
172 ~GameOptionsWindow()
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
173 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
174 DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
175 if (this->reload) _switch_mode = SM_MENU;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
176 }
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
177
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
178 /**
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
179 * Build the dropdown list for a specific widget.
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
180 * @param widget Widget to build list for
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
181 * @param selected_index Currently selected item
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
182 * @return the built dropdown list, or NULL if the widget has no dropdown menu.
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
183 */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
184 DropDownList *BuildDropDownList(int widget, int *selected_index) const
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
185 {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
186 DropDownList *list = NULL;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
187 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
188 case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
189 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
190 *selected_index = this->opt->locale.currency;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
191 StringID *items = BuildCurrencyDropdown();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
192 uint disabled = _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
193 int custom_index = -1;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
194
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
195 /* Add non-custom currencies; sorted naturally */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
196 for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
197 if (*items == STR_GAME_OPTIONS_CURRENCY_CUSTOM) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
198 custom_index = i;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
199 } else {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
200 list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
201 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
202 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
203 list->sort(DropDownListStringItem::NatSortFunc);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
204
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
205 /* Append custom currency at the end */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
206 if (custom_index >= 0) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
207 list->push_back(new DropDownListItem(-1, false)); // separator line
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
208 list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, custom_index, HasBit(disabled, custom_index)));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
209 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
210 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
211 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
212
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
213 case WID_GO_DISTANCE_DROPDOWN: { // Setup distance unit dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
214 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
215 *selected_index = this->opt->locale.units;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
216 const StringID *items = _units_dropdown;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
217 for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
218 list->push_back(new DropDownListStringItem(*items, i, false));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
219 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
220 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
221 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
222
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
223 case WID_GO_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
224 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
225 *selected_index = this->opt->vehicle.road_side;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
226 const StringID *items = _driveside_dropdown;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
227 uint disabled = 0;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
228
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
229 /* You can only change the drive side if you are in the menu or ingame with
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
230 * no vehicles present. In a networking game only the server can change it */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
231 extern bool RoadVehiclesAreBuilt();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
232 if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
233 disabled = ~(1 << this->opt->vehicle.road_side); // disable the other value
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
234 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
235
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
236 for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
237 list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
238 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
239 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
240 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
241
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
242 case WID_GO_TOWNNAME_DROPDOWN: { // Setup townname dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
243 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
244 *selected_index = this->opt->game_creation.town_name;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
245
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
246 int enabled_item = (_game_mode == GM_MENU || Town::GetNumItems() == 0) ? -1 : *selected_index;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
247
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
248 /* Add and sort original townnames generators */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
249 for (int i = 0; i < _nb_orig_names; i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
250 list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
251 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
252 list->sort(DropDownListStringItem::NatSortFunc);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
253
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
254 /* Add and sort newgrf townnames generators */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
255 DropDownList newgrf_names;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
256 for (int i = 0; i < _nb_grf_names; i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
257 int result = _nb_orig_names + i;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
258 newgrf_names.push_back(new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
259 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
260 newgrf_names.sort(DropDownListStringItem::NatSortFunc);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
261
17551
8fb428581ca6 (svn r22315) -Fix (r22314): Update comment as well.
frosch <frosch@openttd.org>
parents: 17550
diff changeset
262 /* Insert newgrf_names at the top of the list */
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
263 if (newgrf_names.size() > 0) {
17550
e80129e532c7 (svn r22314) -Change: Put NewGRF supplied townnames at the top of the dropdown list.
frosch <frosch@openttd.org>
parents: 17548
diff changeset
264 newgrf_names.push_back(new DropDownListItem(-1, false)); // separator line
e80129e532c7 (svn r22314) -Change: Put NewGRF supplied townnames at the top of the dropdown list.
frosch <frosch@openttd.org>
parents: 17548
diff changeset
265 list->splice(list->begin(), newgrf_names);
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
266 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
267 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
268 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
269
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
270 case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
271 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
272 *selected_index = _settings_client.gui.autosave;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
273 const StringID *items = _autosave_dropdown;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
274 for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
275 list->push_back(new DropDownListStringItem(*items, i, false));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
276 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
277 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
278 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
279
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
280 case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
281 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
282 for (uint i = 0; i < _languages.Length(); i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
283 if (&_languages[i] == _current_language) *selected_index = i;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
284 list->push_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
285 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
286 list->sort(DropDownListStringItem::NatSortFunc);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
287 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
288 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
289
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
290 case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
291 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
292 *selected_index = GetCurRes();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
293 for (int i = 0; i < _num_resolutions; i++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
294 list->push_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
295 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
296 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
297
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
298 case WID_GO_SCREENSHOT_DROPDOWN: // Setup screenshot format dropdown
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
299 list = new DropDownList();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
300 *selected_index = _cur_screenshot_format;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
301 for (uint i = 0; i < _num_screenshot_formats; i++) {
18925
367a6d3cc642 (svn r23775) -Change: Hide the PCX screenshot format from the options window, if a 32bpp blitter is used.
frosch <frosch@openttd.org>
parents: 18908
diff changeset
302 if (!GetScreenshotFormatSupports_32bpp(i) && BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 32) continue;
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
303 list->push_back(new DropDownListStringItem(SPECSTR_SCREENSHOT_START + i, i, false));
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
304 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
305 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
306
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
307 case WID_GO_BASE_GRF_DROPDOWN:
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
308 list = BuiltSetDropDownList<BaseGraphics>(selected_index);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
309 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
310
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
311 case WID_GO_BASE_SFX_DROPDOWN:
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
312 list = BuiltSetDropDownList<BaseSounds>(selected_index);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
313 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
314
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
315 case WID_GO_BASE_MUSIC_DROPDOWN:
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
316 list = BuiltSetDropDownList<BaseMusic>(selected_index);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
317 break;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
318
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
319 default:
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
320 return NULL;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
321 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
322
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
323 return list;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
324 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
325
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
326 virtual void SetStringParameters(int widget) const
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
327 {
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
328 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
329 case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
330 case WID_GO_DISTANCE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_MEASURING_UNITS_IMPERIAL + this->opt->locale.units); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
331 case WID_GO_ROADSIDE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT + this->opt->vehicle.road_side); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
332 case WID_GO_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
333 case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
334 case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
335 case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
336 case WID_GO_SCREENSHOT_DROPDOWN: SetDParam(0, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
337 case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
338 case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
339 case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
340 case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
341 case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
342 }
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
343 }
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
344
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
345 virtual void DrawWidget(const Rect &r, int widget) const
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
346 {
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
347 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
348 case WID_GO_BASE_GRF_DESCRIPTION:
13281
e241d1485669 (svn r17790) -Feature: translatable base sound/graphics set descriptions
rubidium <rubidium@openttd.org>
parents: 13277
diff changeset
349 SetDParamStr(0, BaseGraphics::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
350 DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
351 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
352
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
353 case WID_GO_BASE_SFX_DESCRIPTION:
13281
e241d1485669 (svn r17790) -Feature: translatable base sound/graphics set descriptions
rubidium <rubidium@openttd.org>
parents: 13277
diff changeset
354 SetDParamStr(0, BaseSounds::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
355 DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
356 break;
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
357
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
358 case WID_GO_BASE_MUSIC_DESCRIPTION:
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
359 SetDParamStr(0, BaseMusic::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
360 DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
361 break;
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
362 }
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
363 }
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
364
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
365 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
366 {
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
367 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
368 case WID_GO_BASE_GRF_DESCRIPTION:
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
369 /* Find the biggest description for the default size. */
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
370 for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
13281
e241d1485669 (svn r17790) -Feature: translatable base sound/graphics set descriptions
rubidium <rubidium@openttd.org>
parents: 13277
diff changeset
371 SetDParamStr(0, BaseGraphics::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
372 size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
373 }
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
374 break;
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
375
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
376 case WID_GO_BASE_GRF_STATUS:
12704
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
377 /* Find the biggest description for the default size. */
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
378 for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
12771
7a25de72eb71 (svn r17241) -Change: make a distinction between missing and corrupted data files. If (at least) one data file is missing do not consider the set to be useable. Do also no autodetect sets with missing files.
rubidium <rubidium@openttd.org>
parents: 12704
diff changeset
379 uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
7a25de72eb71 (svn r17241) -Change: make a distinction between missing and corrupted data files. If (at least) one data file is missing do not consider the set to be useable. Do also no autodetect sets with missing files.
rubidium <rubidium@openttd.org>
parents: 12704
diff changeset
380 if (invalid_files == 0) continue;
12704
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
381
12771
7a25de72eb71 (svn r17241) -Change: make a distinction between missing and corrupted data files. If (at least) one data file is missing do not consider the set to be useable. Do also no autodetect sets with missing files.
rubidium <rubidium@openttd.org>
parents: 12704
diff changeset
382 SetDParam(0, invalid_files);
12704
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
383 *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
384 }
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
385 break;
dba29babe01f (svn r17167) -Fix: don't resize the 'base grf status' text part in the game options window when there is no base graphics set that misses files.
rubidium <rubidium@openttd.org>
parents: 12684
diff changeset
386
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
387 case WID_GO_BASE_SFX_DESCRIPTION:
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
388 /* Find the biggest description for the default size. */
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
389 for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
13281
e241d1485669 (svn r17790) -Feature: translatable base sound/graphics set descriptions
rubidium <rubidium@openttd.org>
parents: 13277
diff changeset
390 SetDParamStr(0, BaseSounds::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
391 size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
392 }
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
393 break;
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
394
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
395 case WID_GO_BASE_MUSIC_DESCRIPTION:
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
396 /* Find the biggest description for the default size. */
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
397 for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
398 SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
399 size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
400 }
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
401 break;
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
402
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
403 case WID_GO_BASE_MUSIC_STATUS:
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
404 /* Find the biggest description for the default size. */
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
405 for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
406 uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
407 if (invalid_files == 0) continue;
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
408
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
409 SetDParam(0, invalid_files);
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
410 *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
411 }
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
412 break;
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
413
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
414 default: {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
415 int selected;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
416 DropDownList *list = this->BuildDropDownList(widget, &selected);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
417 if (list != NULL) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
418 /* Find the biggest item for the default size. */
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
419 for (DropDownList::iterator it = list->begin(); it != list->end(); it++) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
420 static const Dimension extra = {WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM};
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
421 Dimension string_dim;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
422 int width = (*it)->Width();
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
423 string_dim.width = width + extra.width;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
424 string_dim.height = (*it)->Height(width) + extra.height;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
425 *size = maxdim(*size, string_dim);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
426 delete *it;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
427 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
428 delete list;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
429 }
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
430 }
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
431 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433
14409
1eaefde497fd (svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents: 14385
diff changeset
434 virtual void OnClick(Point pt, int widget, int click_count)
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
435 {
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
436 if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
437 if (BaseGraphics::GetUsedSet() == NULL) return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
438
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
439 ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
440 return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
441 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
442 if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
443 if (BaseSounds::GetUsedSet() == NULL) return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
444
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
445 ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
446 return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
447 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
448 if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
449 if (BaseMusic::GetUsedSet() == NULL) return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
450
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
451 ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
452 return;
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
453 }
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
454 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
455 case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
456 /* 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
457 if (!ToggleFullScreen(!_fullscreen)) {
14645
b7a22979b84e (svn r19224) -Codechange: change parameters passed to ShowErrorMessage() a bit
smatz <smatz@openttd.org>
parents: 14510
diff changeset
458 ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
459 }
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
460 this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
461 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
462 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
463
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
464 default: {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
465 int selected;
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
466 DropDownList *list = this->BuildDropDownList(widget, &selected);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
467 if (list != NULL) {
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
468 ShowDropDownList(this, list, selected, widget);
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
469 }
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
470 break;
17548
c0fce44f4000 (svn r22312) -Codechange: Add GameOptionsWindow::BuildDropDownList() for construction of all dropdown lists in the GameOptionsWindow.
frosch <frosch@openttd.org>
parents: 17486
diff changeset
471 }
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
472 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
473 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
474
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
475 /**
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
476 * Set the base media set.
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
477 * @param index the index of the media set
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
478 * @tparam T class of media set
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
479 */
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
480 template <class T>
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
481 void SetMediaSet(int index)
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
482 {
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
483 if (_game_mode == GM_MENU) {
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
484 const char *name = T::GetSet(index)->name;
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
485
18362
d7607ed4eef6 (svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents: 17827
diff changeset
486 free(T::ini_set);
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
487 T::ini_set = strdup(name);
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
488
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
489 T::SetSet(name);
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
490 this->reload = true;
13169
1f44cefc7825 (svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents: 13139
diff changeset
491 this->InvalidateData();
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
492 }
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
493 }
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
494
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
495 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
496 {
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
497 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
498 case WID_GO_CURRENCY_DROPDOWN: // Currency
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
499 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
500 this->opt->locale.currency = index;
16302
78ed3fe0f2ee (svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
rubidium <rubidium@openttd.org>
parents: 16034
diff changeset
501 ReInitAllWindows();
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
502 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
503
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
504 case WID_GO_DISTANCE_DROPDOWN: // 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
505 this->opt->locale.units = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
506 MarkWholeScreenDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
507 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
508
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
509 case WID_GO_ROADSIDE_DROPDOWN: // Road side
11075
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
510 if (this->opt->vehicle.road_side != index) { // only change if setting changed
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
511 uint i;
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
512 if (GetSettingFromName("vehicle.road_side", &i) == NULL) NOT_REACHED();
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
513 SetSettingValue(i, index);
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
514 MarkWholeScreenDirty();
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
515 }
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
516 break;
adc269893bd0 (svn r15416) -Fix (r15412): revert the removal of the road side drop down box handling.
rubidium <rubidium@openttd.org>
parents: 11071
diff changeset
517
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
518 case WID_GO_TOWNNAME_DROPDOWN: // Town names
11973
e17a54c88806 (svn r16379) -Codechange: remove GetNumTowns(), GetNumIndustries() and GetActiveCompanyCount(), use PoolItem::GetNumItems() instead
smatz <smatz@openttd.org>
parents: 11939
diff changeset
519 if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
520 this->opt->game_creation.town_name = index;
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
521 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
522 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
523 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
524
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
525 case WID_GO_AUTOSAVE_DROPDOWN: // 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
526 _settings_client.gui.autosave = index;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
527 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
528 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
529
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
530 case WID_GO_LANG_DROPDOWN: // Change interface language
16448
a94bb23bd67b (svn r21164) -Codechange: replace the hardcoded array of language metadata with a list
rubidium <rubidium@openttd.org>
parents: 16447
diff changeset
531 ReadLanguagePack(&_languages[index]);
16823
3a844b1791a9 (svn r21557) -Change: close the query windows when changing the language as often the strings are partly translated, which causes trouble in some cases
rubidium <rubidium@openttd.org>
parents: 16772
diff changeset
532 DeleteWindowByClass(WC_QUERY_STRING);
18431
d167deadae56 (svn r23273) -Codechange: allow passing a MissingGlyphSearcher to CheckForMissingGlyphs (default to the language pack strings)
rubidium <rubidium@openttd.org>
parents: 18427
diff changeset
533 CheckForMissingGlyphs();
13950
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13834
diff changeset
534 UpdateAllVirtCoords();
12272
c8708dfd0118 (svn r16687) -Codechange: Perform re-initialization of windows with nested widgets after a language change.
alberth <alberth@openttd.org>
parents: 12262
diff changeset
535 ReInitAllWindows();
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
536 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
537
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
538 case WID_GO_RESOLUTION_DROPDOWN: // 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
539 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
540 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
541 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
542 break;
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
543
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
544 case WID_GO_SCREENSHOT_DROPDOWN: // Change screenshot format
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
545 SetScreenshotFormat(index);
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
546 this->SetDirty();
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
547 break;
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
548
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
549 case WID_GO_BASE_GRF_DROPDOWN:
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
550 this->SetMediaSet<BaseGraphics>(index);
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
551 break;
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
552
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
553 case WID_GO_BASE_SFX_DROPDOWN:
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
554 this->SetMediaSet<BaseSounds>(index);
11049
ed93627e213f (svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents: 11000
diff changeset
555 break;
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
556
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
557 case WID_GO_BASE_MUSIC_DROPDOWN:
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
558 this->SetMediaSet<BaseMusic>(index);
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
559 break;
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
560 }
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
561 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
563 /**
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
564 * Some data on this window has become invalid.
17826
03d75c842b87 (svn r22617) -Codechange: Add GameOptionsInvalidationData enum for data values for Window::OnInvalidateData() of windows with class WC_GAME_OPTIONS.
frosch <frosch@openttd.org>
parents: 17645
diff changeset
565 * @param data Information about the changed data. @see GameOptionsInvalidationData
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
566 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
567 */
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
568 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
569 {
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
570 if (!gui_scope) return;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
571 this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _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
572
12678
ea203bb44a25 (svn r17133) -Codechange: generalise the code that searches for base graphics
rubidium <rubidium@openttd.org>
parents: 12676
diff changeset
573 bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
574 this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
575
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
576 for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
577 this->SetWidgetDisabledState(WID_GO_BASE_GRF_TEXTFILE + tft, BaseGraphics::GetUsedSet() == NULL || BaseGraphics::GetUsedSet()->GetTextfile(tft) == NULL);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
578 this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == NULL || BaseSounds::GetUsedSet()->GetTextfile(tft) == NULL);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
579 this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_TEXTFILE + tft, BaseMusic::GetUsedSet() == NULL || BaseMusic::GetUsedSet()->GetTextfile(tft) == NULL);
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
580 }
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
581
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
582 missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
583 this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
12517
71027f744a29 (svn r16954) -Codechange: make the Game Options window use the nested widget system.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
584 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
587 static const NWidgetPart _nested_game_options_widgets[] = {
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
588 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
589 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
590 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
591 EndContainer(),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
592 NWidget(WWT_PANEL, COLOUR_GREY, WID_GO_BACKGROUND), SetPIP(6, 6, 10),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
593 NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
594 NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
595 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
596 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
597 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
598 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_ROAD_VEHICLES_FRAME, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
599 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_ROADSIDE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
600 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
601 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
602 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_AUTOSAVE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
603 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
604 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
605 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP), SetFill(1, 0), SetPadding(0, 0, 3, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
606 NWidget(NWID_HORIZONTAL),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
607 NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
608 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
609 EndContainer(),
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
610 EndContainer(),
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
611 EndContainer(),
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
612
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
613 NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
614 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_MEASURING_UNITS_FRAME, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
615 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_DISTANCE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_MEASURING_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
616 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
617 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
618 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_TOWNNAME_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
619 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
620 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
621 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_LANG_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
622 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
623 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_SCREENSHOT_FORMAT, STR_NULL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
624 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_SCREENSHOT_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_SCREENSHOT_FORMAT_TOOLTIP), SetFill(1, 0),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
625 EndContainer(),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
626 NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
627 EndContainer(),
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
628 EndContainer(),
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
629
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
630 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
631 NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
632 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
633 NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
634 EndContainer(),
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
635 NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
636 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
637 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
638 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
639 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
640 EndContainer(),
11939
577d93a5e10d (svn r16342) -Feature(tte): Display base graphics description in game options window.
frosch <frosch@openttd.org>
parents: 11913
diff changeset
641 EndContainer(),
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
642
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
643 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
13670
2e7ff39e2ec6 (svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents: 13665
diff changeset
644 NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
645 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
646 NWidget(NWID_SPACER), SetFill(1, 0),
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
647 EndContainer(),
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
648 NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_SFX_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
649 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
650 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
651 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
652 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
653 EndContainer(),
12684
b056ac99f230 (svn r17139) -Change: add the concept of sound sets
rubidium <rubidium@openttd.org>
parents: 12683
diff changeset
654 EndContainer(),
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
655
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
656 NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
657 NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
658 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
659 NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
660 EndContainer(),
19169
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
661 NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
662 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
663 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
664 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
665 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
09e322acb393 (svn r24037) -Feature: Allow display of baseset textfiles. (LordAro)
frosch <frosch@openttd.org>
parents: 18925
diff changeset
666 EndContainer(),
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14037
diff changeset
667 EndContainer(),
11513
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
668 EndContainer(),
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
669 };
060289e229f7 (svn r15874) -Codechange: New widgets for the game options window.
yexo <yexo@openttd.org>
parents: 11507
diff changeset
670
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
671 static const WindowDesc _game_options_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
672 WDP_CENTER, 0, 0,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
673 WC_GAME_OPTIONS, WC_NONE,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
674 WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
675 _nested_game_options_widgets, lengthof(_nested_game_options_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
676 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
677
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
678 /** Open the game options window. */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
679 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
680 {
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
681 DeleteWindowByClass(WC_GAME_OPTIONS);
9291
f9b184a11fea (svn r13158) -Codechange: make a class of the GameOptionsWindow.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
682 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
683 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
684
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
685 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
686
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
687 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
688
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
689 class GameDifficultyWindow : public Window {
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
690 private:
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
691 /* 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
692 GameSettings opt_mod_temp;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
693
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
694 public:
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
695 /** The number of difficulty settings */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
696 static const uint GAME_DIFFICULTY_NUM = 18;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
697 /** The number of widgets per difficulty setting */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
698 static const uint WIDGETS_PER_DIFFICULTY = 3;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
699
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
700 GameDifficultyWindow(const WindowDesc *desc) : Window()
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
701 {
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
702 this->InitNested(desc, WN_GAME_OPTIONS_GAME_DIFFICULTY);
13131
f78f54c02ea0 (svn r17636) -Codechange: make the difficulty setting window nested
rubidium <rubidium@openttd.org>
parents: 13088
diff changeset
703
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
704 /* Setup disabled buttons when creating window
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
705 * disable all other difficulty buttons during gameplay except for 'custom' */
13139
3064addfd0ec (svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
rubidium <rubidium@openttd.org>
parents: 13136
diff changeset
706 this->SetWidgetsDisabledState(_game_mode != GM_MENU,
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
707 WID_GD_LVL_EASY,
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
708 WID_GD_LVL_MEDIUM,
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
709 WID_GD_LVL_HARD,
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
710 WID_GD_LVL_CUSTOM,
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
711 WIDGET_LIST_END);
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
712 this->SetWidgetDisabledState(WID_GD_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
713 this->SetWidgetDisabledState(WID_GD_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
17827
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
714
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
715 /* Read data */
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
716 this->OnInvalidateData(GOID_DIFFICULTY_CHANGED);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
717 }
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
718
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
719 virtual void SetStringParameters(int widget) const
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
720 {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
721 widget -= WID_GD_OPTIONS_START;
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
722 if (widget < 0 || (widget % 3) != 2) return;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
723
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
724 widget /= 3;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
725
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
726 uint i;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
727 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + widget;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
728 int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
19336
ad5c89d6d7e9 (svn r24233) -Codechange: Rename 'val_str' to 'str_val' to better match with 'strval' in the ini files.
alberth <alberth@openttd.org>
parents: 19321
diff changeset
729 SetDParam(0, sd->desc.str_val + value);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
730 }
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
731
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
732 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
733 {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
734 /* Only for the 'descriptions' */
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
735 int index = widget - WID_GD_OPTIONS_START;
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
736 if (index < 0 || (index % 3) != 2) return;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
737
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
738 index /= 3;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
739
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
740 uint i;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
741 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + index;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
742 const SettingDescBase *sdb = &sd->desc;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
743
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
744 /* Get the string and try all strings from the smallest to the highest value */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
745 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
746 for (int32 value = sdb->min; (uint32)value <= sdb->max; value += sdb->interval) {
19336
ad5c89d6d7e9 (svn r24233) -Codechange: Rename 'val_str' to 'str_val' to better match with 'strval' in the ini files.
alberth <alberth@openttd.org>
parents: 19321
diff changeset
747 SetDParam(0, sdb->str_val + value);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
748 *size = maxdim(*size, GetStringBoundingBox(str));
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
749 }
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
750 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
751
14409
1eaefde497fd (svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents: 14385
diff changeset
752 virtual void OnClick(Point pt, int widget, int click_count)
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
753 {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
754 if (widget >= WID_GD_OPTIONS_START) {
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
755 widget -= WID_GD_OPTIONS_START;
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
756 if ((widget % 3) == 2) return;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
757
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
758 /* Don't allow clients to make any changes */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
759 if (_networking && !_network_server) return;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
760
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
761 uint i;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
762 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + (widget / 3);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
763 const SettingDescBase *sdb = &sd->desc;
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
764
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
765 int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
766 if (widget % 3 == 1) {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
767 /* Increase button clicked */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
768 val = min(val + sdb->interval, (int32)sdb->max);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
769 } else {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
770 /* Decrease button clicked */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
771 val -= sdb->interval;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
772 val = max(val, sdb->min);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
773 }
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
774
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
775 /* save value in temporary variable */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
776 WriteValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv, val);
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
777 this->RaiseWidget(WID_GD_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
778 SetDifficultyLevel(3, &this->opt_mod_temp.difficulty); // set difficulty level to custom
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
779 this->LowerWidget(WID_GD_LVL_CUSTOM);
13169
1f44cefc7825 (svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents: 13139
diff changeset
780 this->InvalidateData();
14330
9caa7d57a6e3 (svn r18883) -Codechange: warn in the difficulty and AI configuration window when setting the number of AIs to non-zero when you don't have AIs
rubidium <rubidium@openttd.org>
parents: 14258
diff changeset
781
14510
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14493
diff changeset
782 if (widget / 3 == 0 &&
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14493
diff changeset
783 AI::GetInfoList()->size() == 0 &&
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14493
diff changeset
784 this->opt_mod_temp.difficulty.max_no_competitors != 0) {
14645
b7a22979b84e (svn r19224) -Codechange: change parameters passed to ShowErrorMessage() a bit
smatz <smatz@openttd.org>
parents: 14510
diff changeset
785 ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL);
14330
9caa7d57a6e3 (svn r18883) -Codechange: warn in the difficulty and AI configuration window when setting the number of AIs to non-zero when you don't have AIs
rubidium <rubidium@openttd.org>
parents: 14258
diff changeset
786 }
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
787 return;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
788 }
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
789
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
790 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
791 case WID_GD_LVL_EASY:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
792 case WID_GD_LVL_MEDIUM:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
793 case WID_GD_LVL_HARD:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
794 case WID_GD_LVL_CUSTOM:
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
795 /* temporarily change difficulty level */
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
796 this->RaiseWidget(WID_GD_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
797 SetDifficultyLevel(widget - WID_GD_LVL_EASY, &this->opt_mod_temp.difficulty);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
798 this->LowerWidget(WID_GD_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
13169
1f44cefc7825 (svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents: 13139
diff changeset
799 this->InvalidateData();
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
800 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
801
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
802 case WID_GD_HIGHSCORE: // Highscore Table
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
803 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
804 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
805
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
806 case WID_GD_ACCEPT: { // Save button - save changes
16959
55b2bec60c52 (svn r21695) -Codechange: add helper function to get the currently applicable GameSettings object
yexo <yexo@openttd.org>
parents: 16945
diff changeset
807 GameSettings *opt_ptr = &GetGameSettings();
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
808
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
809 uint i;
13088
1008c63fa996 (svn r17588) -Fix [FS#3220]: erroneous message about changing the difficulty level
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
810 GetSettingFromName("difficulty.diff_level", &i);
1008c63fa996 (svn r17588) -Fix [FS#3220]: erroneous message about changing the difficulty level
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
811 DoCommandP(0, i, this->opt_mod_temp.difficulty.diff_level, CMD_CHANGE_SETTING);
1008c63fa996 (svn r17588) -Fix [FS#3220]: erroneous message about changing the difficulty level
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
812
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
813 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i);
9359
c3a0ec3104c9 (svn r13256) -Codechange: merge the OPTS and PATS chuncks.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
814 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
815 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
816 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
817 /* 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
818 if (new_val != cur_val) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
819 DoCommandP(0, i + btn, new_val, CMD_CHANGE_SETTING);
9346
0c181c088ed8 (svn r13242) -Codechange: remove _opt_ptr.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
820 }
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
821 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
822 delete this;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
823 /* 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
824 * 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
825 * are loaded correctly. */
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
826 if (_game_mode == GM_EDITOR) StartupEconomy();
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
827 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
828 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
829
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
830 case WID_GD_CANCEL: // Cancel button - close window, abandon changes
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
831 delete this;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
832 break;
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
833 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
834 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
835
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
836 /**
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
837 * Some data on this window has become invalid.
17826
03d75c842b87 (svn r22617) -Codechange: Add GameOptionsInvalidationData enum for data values for Window::OnInvalidateData() of windows with class WC_GAME_OPTIONS.
frosch <frosch@openttd.org>
parents: 17645
diff changeset
838 * @param data Information about the changed data. @see GameOptionsInvalidationData
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
839 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
840 */
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
841 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
842 {
17486
e7672bafbe1c (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents: 17456
diff changeset
843 if (!gui_scope) return;
17827
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
844
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
845 if (data == GOID_DIFFICULTY_CHANGED) {
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
846 /* Window was created or settings were changed on server. Reread everything. */
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
847
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
848 /* Copy current settings (ingame or in intro) to temporary holding place
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
849 * change that when setting stuff, copy back on clicking 'OK' */
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
850 this->opt_mod_temp = GetGameSettings();
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
851
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
852 this->LowerWidget(WID_GD_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
17827
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
853 }
808fd7d57d64 (svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
frosch <frosch@openttd.org>
parents: 17826
diff changeset
854
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
855 uint i;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
856 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
857 for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
858 const SettingDescBase *sdb = &sd->desc;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
859 /* skip deprecated difficulty options */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
860 if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
861 int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
13139
3064addfd0ec (svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
rubidium <rubidium@openttd.org>
parents: 13136
diff changeset
862 bool disable = (sd->desc.flags & SGF_NEWGAME_ONLY) &&
3064addfd0ec (svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
rubidium <rubidium@openttd.org>
parents: 13136
diff changeset
863 (_game_mode == GM_NORMAL ||
3064addfd0ec (svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
rubidium <rubidium@openttd.org>
parents: 13136
diff changeset
864 (_game_mode == GM_EDITOR && (sd->desc.flags & SGF_SCENEDIT_TOO) == 0));
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
865
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
866 this->SetWidgetDisabledState(WID_GD_OPTIONS_START + i * 3 + 0, disable || sdb->min == value);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
867 this->SetWidgetDisabledState(WID_GD_OPTIONS_START + i * 3 + 1, disable || sdb->max == (uint32)value);
9231
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
868 }
6ddeba445c3a (svn r13097) -Codechange: make a class of the GameDifficultyWindow.
glx <glx@openttd.org>
parents: 9164
diff changeset
869 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
870 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
871
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
872 static NWidgetBase *MakeDifficultyOptionsWidgets(int *biggest_index)
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
873 {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
874 NWidgetVertical *vert_desc = new NWidgetVertical;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
875
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
876 int widnum = WID_GD_OPTIONS_START;
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
877 uint i, j;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
878 const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
879
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
880 for (i = 0, j = 0; i < GameDifficultyWindow::GAME_DIFFICULTY_NUM; i++, sd++, widnum += GameDifficultyWindow::WIDGETS_PER_DIFFICULTY) {
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
881 if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
882
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
883 NWidgetHorizontal *hor = new NWidgetHorizontal;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
884
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
885 /* [<] button. */
15795
c9cf5fe6d6a1 (svn r20470) -Codechange: Make arrow buttons lower and raise like other buttons when clicked.
frosch <frosch@openttd.org>
parents: 15787
diff changeset
886 NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHARROWBTN, COLOUR_YELLOW, widnum, AWV_DECREASE, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
887 hor->Add(leaf);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
888
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
889 /* [>] button. */
15795
c9cf5fe6d6a1 (svn r20470) -Codechange: Make arrow buttons lower and raise like other buttons when clicked.
frosch <frosch@openttd.org>
parents: 15787
diff changeset
890 leaf = new NWidgetLeaf(WWT_PUSHARROWBTN, COLOUR_YELLOW, widnum + 1, AWV_INCREASE, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
891 hor->Add(leaf);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
892
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
893 /* Some spacing between the text and the description */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
894 NWidgetSpacer *spacer = new NWidgetSpacer(5, 0);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
895 hor->Add(spacer);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
896
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
897 /* Descriptive text. */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
898 leaf = new NWidgetLeaf(WWT_TEXT, COLOUR_YELLOW, widnum + 2, STR_DIFFICULTY_LEVEL_SETTING_MAXIMUM_NO_COMPETITORS + (j++), STR_NULL);
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
899 leaf->SetFill(1, 0);
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
900 hor->Add(leaf);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
901 vert_desc->Add(hor);
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
902
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
903 /* Space vertically */
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
904 vert_desc->Add(new NWidgetSpacer(0, 2));
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
905 }
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
906 *biggest_index = widnum - 1;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
907 return vert_desc;
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
908 }
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
909
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
910
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
911 /** Widget definition for the game difficulty settings window */
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
912 static const NWidgetPart _nested_game_difficulty_widgets[] = {
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
913 NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_DIFFICULTY_LEVEL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
914 NWidget(WWT_PANEL, COLOUR_MAUVE),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
915 NWidget(NWID_VERTICAL), SetPIP(2, 0, 2),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
916 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 0, 10),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
917 NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GD_LVL_EASY), SetDataTip(STR_DIFFICULTY_LEVEL_EASY, STR_NULL), SetFill(1, 0),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
918 NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GD_LVL_MEDIUM), SetDataTip(STR_DIFFICULTY_LEVEL_MEDIUM, STR_NULL), SetFill(1, 0),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
919 NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GD_LVL_HARD), SetDataTip(STR_DIFFICULTY_LEVEL_HARD, STR_NULL), SetFill(1, 0),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
920 NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GD_LVL_CUSTOM), SetDataTip(STR_DIFFICULTY_LEVEL_CUSTOM, STR_NULL), SetFill(1, 0),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
921 EndContainer(),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
922 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
923 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GD_HIGHSCORE), SetDataTip(STR_DIFFICULTY_LEVEL_HIGH_SCORE_BUTTON, STR_NULL), SetFill(1, 0),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
924 EndContainer(),
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
925 EndContainer(),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
926 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
927 NWidget(WWT_PANEL, COLOUR_MAUVE),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
928 NWidget(NWID_VERTICAL), SetPIP(3, 0, 1),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
929 NWidget(NWID_HORIZONTAL), SetPIP(5, 0, 5),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
930 NWidgetFunction(MakeDifficultyOptionsWidgets),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
931 EndContainer(),
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
932 EndContainer(),
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
933 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
934 NWidget(WWT_PANEL, COLOUR_MAUVE),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
935 NWidget(NWID_VERTICAL), SetPIP(2, 0, 2),
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
936 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 0, 10),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
937 NWidget(NWID_SPACER), SetFill(1, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
938 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_GD_ACCEPT), SetDataTip(STR_DIFFICULTY_LEVEL_SAVE, STR_NULL), SetFill(1, 0),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
939 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_GD_CANCEL), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), SetFill(1, 0),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13695
diff changeset
940 NWidget(NWID_SPACER), SetFill(1, 0),
13134
54b65f0fc0ea (svn r17639) -Codechange: let the difficulty settings GUI make really use the nested widget features
rubidium <rubidium@openttd.org>
parents: 13132
diff changeset
941 EndContainer(),
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
942 EndContainer(),
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
943 EndContainer(),
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
944 };
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
945
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
946 /** Window definition for the game difficulty settings window */
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
947 static const WindowDesc _game_difficulty_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
948 WDP_CENTER, 0, 0,
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
949 WC_GAME_OPTIONS, WC_NONE,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
950 WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
951 _nested_game_difficulty_widgets, lengthof(_nested_game_difficulty_widgets)
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
952 );
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
953
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
954 /** Open the game-difficulty window. */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
955 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
956 {
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
957 DeleteWindowByClass(WC_GAME_OPTIONS);
13132
dc0ab6265137 (svn r17637) -Codechange: move the game difficulty window's window/widget description below the window class
rubidium <rubidium@openttd.org>
parents: 13131
diff changeset
958 new GameDifficultyWindow(&_game_difficulty_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
959 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
961 static int SETTING_HEIGHT = 11; ///< Height of a single setting in the tree view in pixels
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
962 static const int LEVEL_WIDTH = 15; ///< Indenting width of a sub-page in pixels
10538
24ddd67a00be (svn r14795) -Codechange: replace a magic number with a constant (Alberth)
rubidium <rubidium@openttd.org>
parents: 10537
diff changeset
963
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
964 /**
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
965 * Flags for #SettingEntry
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
966 * @note The #SEF_BUTTONS_MASK matches expectations of the formal parameter 'state' of #DrawArrowButtons
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
967 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
968 enum SettingEntryFlags {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
969 SEF_LEFT_DEPRESSED = 0x01, ///< Of a numeric setting entry, the left button is depressed
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
970 SEF_RIGHT_DEPRESSED = 0x02, ///< Of a numeric setting entry, the right button is depressed
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
971 SEF_BUTTONS_MASK = (SEF_LEFT_DEPRESSED | SEF_RIGHT_DEPRESSED), ///< Bit-mask for button flags
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
972
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
973 SEF_LAST_FIELD = 0x04, ///< This entry is the last one in a (sub-)page
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
974 SEF_FILTERED = 0x08, ///< Entry is hidden by the string filter
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
975
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
976 /* Entry kind */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
977 SEF_SETTING_KIND = 0x10, ///< Entry kind: Entry is a setting
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
978 SEF_SUBTREE_KIND = 0x20, ///< Entry kind: Entry is a sub-tree
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
979 SEF_KIND_MASK = (SEF_SETTING_KIND | SEF_SUBTREE_KIND), ///< Bit-mask for fetching entry kind
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
980 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
981
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
982 struct SettingsPage; // Forward declaration
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
983
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
984 /** Data fields for a sub-page (#SEF_SUBTREE_KIND kind)*/
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
985 struct SettingEntrySubtree {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
986 SettingsPage *page; ///< Pointer to the sub-page
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
987 bool folded; ///< Sub-page is folded (not visible except for its title)
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
988 StringID title; ///< Title of the sub-page
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
989 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
990
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
991 /** Data fields for a single setting (#SEF_SETTING_KIND kind) */
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
992 struct SettingEntrySetting {
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
993 const char *name; ///< Name of the setting
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
994 const SettingDesc *setting; ///< Setting description of the setting
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
995 uint index; ///< Index of the setting in the settings table
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
996 };
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
997
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
998 /** How the list of advanced settings is filtered. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
999 enum RestrictionMode {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1000 RM_ALL, ///< List all settings regardless of the default/newgame/... values.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1001 RM_CHANGED_AGAINST_DEFAULT, ///< Show only settings which are different compared to default values.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1002 RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL, ///< Show only non-local settings which are different compared to default values.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1003 RM_CHANGED_AGAINST_NEW, ///< Show only settings which are different compared to the user's new game setting values.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1004 RM_END, ///< End for iteration.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1005 };
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1006
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1007 /** Data structure describing a single setting in a tab */
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1008 struct SettingEntry {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1009 byte flags; ///< Flags of the setting entry. @see SettingEntryFlags
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1010 byte level; ///< Nesting level of this setting entry
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1011 union {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1012 SettingEntrySetting entry; ///< Data fields if entry is a setting
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1013 SettingEntrySubtree sub; ///< Data fields if entry is a sub-page
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1014 } d; ///< Data fields for each kind
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1015
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1016 SettingEntry(const char *nm);
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1017 SettingEntry(SettingsPage *sub, StringID title);
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1018
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1019 void Init(byte level);
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1020 void FoldAll();
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1021 void UnFoldAll();
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1022 void SetButtons(byte new_val);
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1023
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1024 /**
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1025 * Set whether this is the last visible entry of the parent node.
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1026 * @param last_field Value to set
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1027 */
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1028 void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1029
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1030 uint Length() const;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1031 void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1032 bool IsVisible(const SettingEntry *item) const;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1033 SettingEntry *FindEntry(uint row, uint *cur_row);
19339
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1034 uint GetMaxHelpHeight(int maxw);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1035
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1036 bool IsFiltered() const;
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1037 bool UpdateFilterState(StringFilter &filter, bool force_visible, RestrictionMode mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1038
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1039 uint Draw(GameSettings *settings_ptr, int base_x, int base_y, int max_x, uint first_row, uint max_row, uint cur_row, uint parent_last, SettingEntry *selected);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1040
19339
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1041 /**
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1042 * Get the help text of a single setting.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1043 * @return The requested help text.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1044 */
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1045 inline StringID GetHelpText()
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1046 {
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1047 assert((this->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1048 return this->d.entry.setting->desc.str_help;
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1049 }
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1050
19396
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1051 void SetValueDParams(uint first_param, int32 value);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1052
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1053 private:
19395
b68bc7441916 (svn r24296) -Codechange: No need to pass a member variable to a member function.
frosch <frosch@openttd.org>
parents: 19342
diff changeset
1054 void DrawSetting(GameSettings *settings_ptr, int x, int y, int max_x, int state, bool highlight);
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1055 bool IsVisibleByRestrictionMode(RestrictionMode mode) const;
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1056 };
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1057
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1058 /** Data structure describing one page of settings in the settings window. */
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1059 struct SettingsPage {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1060 SettingEntry *entries; ///< Array of setting entries of the page.
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1061 byte num; ///< Number of entries on the page (statically filled).
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1062
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1063 void Init(byte level = 0);
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1064 void FoldAll();
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1065 void UnFoldAll();
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1066
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1067 uint Length() const;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1068 void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1069 bool IsVisible(const SettingEntry *item) const;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1070 SettingEntry *FindEntry(uint row, uint *cur_row) const;
19339
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1071 uint GetMaxHelpHeight(int maxw);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1072
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1073 bool UpdateFilterState(StringFilter &filter, bool force_visible, RestrictionMode mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1074
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1075 uint Draw(GameSettings *settings_ptr, int base_x, int base_y, int max_x, uint first_row, uint max_row, SettingEntry *selected, uint cur_row = 0, uint parent_last = 0) const;
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1076 };
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1077
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
1078
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1079 /* == SettingEntry methods == */
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1080
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1081 /**
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1082 * Constructor for a single setting in the 'advanced settings' window
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1083 * @param nm Name of the setting in the setting table
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1084 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1085 SettingEntry::SettingEntry(const char *nm)
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1086 {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1087 this->flags = SEF_SETTING_KIND;
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1088 this->level = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1089 this->d.entry.name = nm;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1090 this->d.entry.setting = NULL;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1091 this->d.entry.index = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1092 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1093
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1094 /**
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1095 * Constructor for a sub-page in the 'advanced settings' window
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1096 * @param sub Sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1097 * @param title Title of the sub-page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1098 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1099 SettingEntry::SettingEntry(SettingsPage *sub, StringID title)
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1100 {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1101 this->flags = SEF_SUBTREE_KIND;
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1102 this->level = 0;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1103 this->d.sub.page = sub;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1104 this->d.sub.folded = true;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1105 this->d.sub.title = title;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1106 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1107
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1108 /**
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1109 * Initialization of a setting entry
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1110 * @param level Page nesting level of this entry
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1111 */
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1112 void SettingEntry::Init(byte level)
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1113 {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1114 this->level = level;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1115
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1116 switch (this->flags & SEF_KIND_MASK) {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1117 case SEF_SETTING_KIND:
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1118 this->d.entry.setting = GetSettingFromName(this->d.entry.name, &this->d.entry.index);
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1119 assert(this->d.entry.setting != NULL);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1120 break;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1121 case SEF_SUBTREE_KIND:
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1122 this->d.sub.page->Init(level + 1);
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1123 break;
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1124 default: NOT_REACHED();
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1125 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1126 }
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1127
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1128 /** Recursively close all (filtered) folds of sub-pages */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1129 void SettingEntry::FoldAll()
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1130 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1131 if (this->IsFiltered()) return;
12676
d1ed749a9ce5 (svn r17131) -Codechange: apply coding style to some switch statements
smatz <smatz@openttd.org>
parents: 12632
diff changeset
1132 switch (this->flags & SEF_KIND_MASK) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1133 case SEF_SETTING_KIND:
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1134 break;
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1135
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1136 case SEF_SUBTREE_KIND:
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1137 this->d.sub.folded = true;
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1138 this->d.sub.page->FoldAll();
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1139 break;
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1140
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1141 default: NOT_REACHED();
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1142 }
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1143 }
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1144
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1145 /** Recursively open all (filtered) folds of sub-pages */
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1146 void SettingEntry::UnFoldAll()
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1147 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1148 if (this->IsFiltered()) return;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1149 switch (this->flags & SEF_KIND_MASK) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1150 case SEF_SETTING_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1151 break;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1152
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1153 case SEF_SUBTREE_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1154 this->d.sub.folded = false;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1155 this->d.sub.page->UnFoldAll();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1156 break;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1157
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1158 default: NOT_REACHED();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1159 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1160 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1161
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1162 /**
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1163 * Recursively accumulate the folding state of the (filtered) tree.
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1164 * @param[in,out] all_folded Set to false, if one entry is not folded.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1165 * @param[in,out] all_unfolded Set to false, if one entry is folded.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1166 */
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1167 void SettingEntry::GetFoldingState(bool &all_folded, bool &all_unfolded) const
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1168 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1169 if (this->IsFiltered()) return;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1170 switch (this->flags & SEF_KIND_MASK) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1171 case SEF_SETTING_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1172 break;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1173
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1174 case SEF_SUBTREE_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1175 if (this->d.sub.folded) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1176 all_unfolded = false;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1177 } else {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1178 all_folded = false;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1179 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1180 this->d.sub.page->GetFoldingState(all_folded, all_unfolded);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1181 break;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1182
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1183 default: NOT_REACHED();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1184 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1185 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1186
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1187 /**
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1188 * Check whether an entry is visible and not folded or filtered away.
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1189 * Note: This does not consider the scrolling range; it might still require scrolling ot make the setting really visible.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1190 * @param item Entry to search for.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1191 * @return true if entry is visible.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1192 */
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1193 bool SettingEntry::IsVisible(const SettingEntry *item) const
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1194 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1195 if (this->IsFiltered()) return false;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1196 if (this == item) return true;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1197
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1198 switch (this->flags & SEF_KIND_MASK) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1199 case SEF_SETTING_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1200 return false;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1201
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1202 case SEF_SUBTREE_KIND:
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1203 return !this->d.sub.folded && this->d.sub.page->IsVisible(item);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1204
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1205 default: NOT_REACHED();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1206 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1207 }
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1208
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1209 /**
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1210 * Set the button-depressed flags (#SEF_LEFT_DEPRESSED and #SEF_RIGHT_DEPRESSED) to a specified value
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1211 * @param new_val New value for the button flags
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1212 * @see SettingEntryFlags
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1213 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1214 void SettingEntry::SetButtons(byte new_val)
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1215 {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1216 assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1217 this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1218 }
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
1219
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1220 /** Return numbers of rows needed to display the (filtered) entry */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1221 uint SettingEntry::Length() const
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1222 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1223 if (this->IsFiltered()) return 0;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1224 switch (this->flags & SEF_KIND_MASK) {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1225 case SEF_SETTING_KIND:
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1226 return 1;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1227 case SEF_SUBTREE_KIND:
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1228 if (this->d.sub.folded) return 1; // Only displaying the title
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1229
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1230 return 1 + this->d.sub.page->Length(); // 1 extra row for the title
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1231 default: NOT_REACHED();
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1232 }
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1233 }
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1234
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1235 /**
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1236 * Find setting entry at row \a row_num
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1237 * @param row_num Index of entry to return
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1238 * @param cur_row Current row number
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1239 * @return The requested setting entry or \c NULL if it not found (folded or filtered)
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1240 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1241 SettingEntry *SettingEntry::FindEntry(uint row_num, uint *cur_row)
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1242 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1243 if (this->IsFiltered()) return NULL;
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1244 if (row_num == *cur_row) return this;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1245
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1246 switch (this->flags & SEF_KIND_MASK) {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1247 case SEF_SETTING_KIND:
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1248 (*cur_row)++;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1249 break;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1250 case SEF_SUBTREE_KIND:
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1251 (*cur_row)++; // add one for row containing the title
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1252 if (this->d.sub.folded) {
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1253 break;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1254 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1255
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1256 /* sub-page is visible => search it too */
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1257 return this->d.sub.page->FindEntry(row_num, cur_row);
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1258 default: NOT_REACHED();
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1259 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1260 return NULL;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1261 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1262
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1263 /**
19339
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1264 * Get the biggest height of the help text(s), if the width is at least \a maxw. Help text gets wrapped if needed.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1265 * @param maxw Maximal width of a line help text.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1266 * @return Biggest height needed to display any help text of this node (and its descendants).
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1267 */
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1268 uint SettingEntry::GetMaxHelpHeight(int maxw)
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1269 {
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1270 switch (this->flags & SEF_KIND_MASK) {
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1271 case SEF_SETTING_KIND: return GetStringHeight(this->GetHelpText(), maxw);
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1272 case SEF_SUBTREE_KIND: return this->d.sub.page->GetMaxHelpHeight(maxw);
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1273 default: NOT_REACHED();
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1274 }
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1275 }
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1276
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1277 /**
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1278 * Check whether an entry is hidden due to filters
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1279 * @return true if hidden.
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1280 */
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1281 bool SettingEntry::IsFiltered() const
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1282 {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1283 return this->flags & SEF_FILTERED;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1284 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1285
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1286 /**
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1287 * Checks whether an entry shall be made visible based on the restriction mode.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1288 * @param mode The current status of the restriction drop down box.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1289 * @return true if the entry shall be visible.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1290 */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1291 bool SettingEntry::IsVisibleByRestrictionMode(RestrictionMode mode) const
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1292 {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1293 /* There shall not be any restriction, i.e. all settings shall be visible. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1294 if (mode == RM_ALL) return true;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1295
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1296 GameSettings *settings_ptr = &GetGameSettings();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1297 assert((this->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1298 const SettingDesc *sd = this->d.entry.setting;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1299
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1300 if (mode == RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL && (sd->save.conv & SLF_NO_NETWORK_SYNC) != 0) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1301 /* Hide local settings when comparing our settings against those of the server. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1302 return false;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1303 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1304
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1305 /* Read the current value. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1306 const void *var = ResolveVariableAddress(settings_ptr, sd);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1307 int64 current_value = ReadValue(var, sd->save.conv);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1308
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1309 int64 filter_value;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1310
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1311 if (mode == RM_CHANGED_AGAINST_DEFAULT || mode == RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1312 /* This entry shall only be visible, if the value deviates from its default value. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1313
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1314 /* Read the default value. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1315 filter_value = ReadValue(&sd->desc.def, sd->save.conv);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1316 } else {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1317 assert(mode == RM_CHANGED_AGAINST_NEW);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1318 /* This entry shall only be visible, if the value deviates from
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1319 * its value is used when starting a new game. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1320
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1321 /* Make sure we're not comparing the new game settings against itself. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1322 assert(settings_ptr != &_settings_newgame);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1323
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1324 /* Read the new game's value. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1325 var = ResolveVariableAddress(&_settings_newgame, sd);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1326 filter_value = ReadValue(var, sd->save.conv);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1327 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1328
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1329 return current_value != filter_value;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1330 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1331
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1332 /**
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1333 * Update the filter state.
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1334 * @param filter String filter
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1335 * @param force_visible Whether to force all items visible, no matter what (due to filter text; not affected by restriction drop down box).
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1336 * @param mode Additional way of filtering only changed settings on this screen (see restriction drop down box).
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1337 * @return true if item remains visible
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1338 */
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1339 bool SettingEntry::UpdateFilterState(StringFilter &filter, bool force_visible, RestrictionMode mode)
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1340 {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1341 CLRBITS(this->flags, SEF_FILTERED);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1342
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1343 bool visible = true;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1344 switch (this->flags & SEF_KIND_MASK) {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1345 case SEF_SETTING_KIND: {
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1346 if (force_visible !! !filter.IsEmpty()) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1347 /* Process the search text filter for this item. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1348 filter.ResetState();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1349
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1350 const SettingDesc *sd = this->d.entry.setting;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1351 const SettingDescBase *sdb = &sd->desc;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1352
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1353 SetDParam(0, STR_EMPTY);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1354 filter.AddLine(sdb->str);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1355 filter.AddLine(this->GetHelpText());
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1356
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1357 visible = filter.GetState();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1358 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1359 visible = visible && this->IsVisibleByRestrictionMode(mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1360 break;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1361 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1362 case SEF_SUBTREE_KIND: {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1363 if (!force_visible && !filter.IsEmpty()) {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1364 filter.ResetState();
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1365 filter.AddLine(this->d.sub.title);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1366 force_visible = filter.GetState();
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1367 }
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1368 visible = this->d.sub.page->UpdateFilterState(filter, force_visible, mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1369 break;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1370 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1371 default: NOT_REACHED();
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1372 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1373
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1374 if (!visible) SETBITS(this->flags, SEF_FILTERED);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1375 return visible;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1376 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1377
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1378
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1379
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1380 /**
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1381 * Draw a row in the settings panel.
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1382 *
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1383 * See SettingsPage::Draw() for an explanation about how drawing is performed.
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1384 *
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1385 * The \a parent_last parameter ensures that the vertical lines at the left are
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1386 * only drawn when another entry follows, that it prevents output like
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1387 * \verbatim
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1388 * |-- setting
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1389 * |-- (-) - Title
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1390 * | |-- setting
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1391 * | |-- setting
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1392 * \endverbatim
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1393 * The left-most vertical line is not wanted. It is prevented by setting the
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1394 * appropiate bit in the \a parent_last parameter.
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1395 *
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1396 * @param settings_ptr Pointer to current values of all settings
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1397 * @param left Left-most position in window/panel to start drawing \a first_row
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1398 * @param right Right-most x position to draw strings at.
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1399 * @param base_y Upper-most position in window/panel to start drawing \a first_row
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1400 * @param first_row First row number to draw
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1401 * @param max_row Row-number to stop drawing (the row-number of the row below the last row to draw)
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1402 * @param cur_row Current row number (internal variable)
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1403 * @param parent_last Last-field booleans of parent page level (page level \e i sets bit \e i to 1 if it is its last field)
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1404 * @param selected Selected entry by the user.
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1405 * @return Row number of the next row to draw
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1406 */
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1407 uint SettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int base_y, uint first_row, uint max_row, uint cur_row, uint parent_last, SettingEntry *selected)
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1408 {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1409 if (this->IsFiltered()) return cur_row;
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1410 if (cur_row >= max_row) return cur_row;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1411
16441
86fd9bcc9d2f (svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents: 16302
diff changeset
1412 bool rtl = _current_text_dir == TD_RTL;
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1413 int offset = rtl ? -4 : 4;
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1414 int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1415
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1416 int x = rtl ? right : left;
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1417 int y = base_y;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1418 if (cur_row >= first_row) {
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1419 int colour = _colour_gradient[COLOUR_ORANGE][4];
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1420 y = base_y + (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1421
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1422 /* Draw vertical for parent nesting levels */
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1423 for (uint lvl = 0; lvl < this->level; lvl++) {
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1424 if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1425 x += level_width;
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1426 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1427 /* draw own |- prefix */
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1428 int halfway_y = y + SETTING_HEIGHT / 2;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1429 int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1430 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1431 /* Small horizontal line from the last vertical line */
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1432 GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1433 x += level_width;
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1434 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1435
12676
d1ed749a9ce5 (svn r17131) -Codechange: apply coding style to some switch statements
smatz <smatz@openttd.org>
parents: 12632
diff changeset
1436 switch (this->flags & SEF_KIND_MASK) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1437 case SEF_SETTING_KIND:
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1438 if (cur_row >= first_row) {
19395
b68bc7441916 (svn r24296) -Codechange: No need to pass a member variable to a member function.
frosch <frosch@openttd.org>
parents: 19342
diff changeset
1439 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this->flags & SEF_BUTTONS_MASK,
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1440 this == selected);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1441 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1442 cur_row++;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1443 break;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1444 case SEF_SUBTREE_KIND:
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1445 if (cur_row >= first_row) {
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1446 DrawSprite((this->d.sub.folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? x - 8 : x, y + (SETTING_HEIGHT - 11) / 2);
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1447 DrawString(rtl ? left : x + 12, rtl ? x - 12 : right, y, this->d.sub.title);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1448 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1449 cur_row++;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1450 if (!this->d.sub.folded) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1451 if (this->flags & SEF_LAST_FIELD) {
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1452 assert(this->level < sizeof(parent_last));
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1453 SetBit(parent_last, this->level); // Add own last-field state
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1454 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1455
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1456 cur_row = this->d.sub.page->Draw(settings_ptr, left, right, base_y, first_row, max_row, selected, cur_row, parent_last);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1457 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1458 break;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1459 default: NOT_REACHED();
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1460 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1461 return cur_row;
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1462 }
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1463
13509
59959bee9f95 (svn r18028) -Codechange: unglobalise some functions
rubidium <rubidium@openttd.org>
parents: 13419
diff changeset
1464 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd)
12022
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1465 {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1466 if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1467 if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1468 return GetVariableAddress(&Company::Get(_local_company)->settings, &sd->save);
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1469 } else {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1470 return GetVariableAddress(&_settings_client.company, &sd->save);
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1471 }
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1472 } else {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1473 return GetVariableAddress(settings_ptr, &sd->save);
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1474 }
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1475 }
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1476
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1477 /**
19396
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1478 * Set the DParams for drawing the value of a setting.
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1479 * @param first_param First DParam to use
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1480 * @param value Setting value to set params for.
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1481 */
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1482 void SettingEntry::SetValueDParams(uint first_param, int32 value)
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1483 {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1484 assert((this->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1485 const SettingDescBase *sdb = &this->d.entry.setting->desc;
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1486 if (sdb->cmd == SDT_BOOLX) {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1487 SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1488 } else {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1489 if ((sdb->flags & SGF_MULTISTRING) != 0) {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1490 SetDParam(first_param++, sdb->str_val - sdb->min + value);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1491 } else if ((sdb->flags & SGF_DISPLAY_ABS) != 0) {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1492 SetDParam(first_param++, sdb->str_val + ((value >= 0) ? 1 : 0));
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1493 value = abs(value);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1494 } else {
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1495 SetDParam(first_param++, sdb->str_val + ((value == 0 && (sdb->flags & SGF_0ISDISABLED) != 0) ? 1 : 0));
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1496 }
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1497 SetDParam(first_param++, value);
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1498 }
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1499 }
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1500
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1501 /**
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1502 * Private function to draw setting value (button + text + current value)
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1503 * @param settings_ptr Pointer to current values of all settings
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1504 * @param left Left-most position in window/panel to start drawing
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1505 * @param right Right-most position in window/panel to draw
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1506 * @param y Upper-most position in window/panel to start drawing
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1507 * @param state State of the left + right arrow buttons to draw for the setting
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1508 * @param highlight Highlight entry.
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1509 */
19395
b68bc7441916 (svn r24296) -Codechange: No need to pass a member variable to a member function.
frosch <frosch@openttd.org>
parents: 19342
diff changeset
1510 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, int state, bool highlight)
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1511 {
19395
b68bc7441916 (svn r24296) -Codechange: No need to pass a member variable to a member function.
frosch <frosch@openttd.org>
parents: 19342
diff changeset
1512 const SettingDesc *sd = this->d.entry.setting;
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1513 const SettingDescBase *sdb = &sd->desc;
12022
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
1514 const void *var = ResolveVariableAddress(settings_ptr, sd);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1515 bool editable = true;
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1516
16441
86fd9bcc9d2f (svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents: 16302
diff changeset
1517 bool rtl = _current_text_dir == TD_RTL;
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
1518 uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
1519 uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
1520 uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
1521 uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1522
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1523 /* We do not allow changes of some items when we are a client in a networkgame */
17444
bf88fe868439 (svn r22198) -Codechange: make some constants name more explicit
rubidium <rubidium@openttd.org>
parents: 17244
diff changeset
1524 if (!(sd->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(sdb->flags & SGF_PER_COMPANY)) editable = false;
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1525 if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1526 if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1527
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1528 SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
19396
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1529 int32 value = (int32)ReadValue(var, sd->save.conv);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1530 if (sdb->cmd == SDT_BOOLX) {
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1531 /* Draw checkbox for boolean-value either on/off */
19396
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1532 DrawBoolButton(buttons_left, button_y, value != 0, editable);
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1533 } else if ((sdb->flags & SGF_MULTISTRING) != 0) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1534 /* Draw [v] button for settings of an enum-type */
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1535 DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1536 } else {
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1537 /* Draw [<][>] boxes for settings of an integer-type */
19319
a1f6d6da1403 (svn r24208) -Codechange: Cleanup in the drawing routine.
alberth <alberth@openttd.org>
parents: 19317
diff changeset
1538 DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
a1f6d6da1403 (svn r24208) -Codechange: Cleanup in the drawing routine.
alberth <alberth@openttd.org>
parents: 19317
diff changeset
1539 editable && value != (sdb->flags & SGF_0ISDISABLED ? 0 : sdb->min), editable && (uint32)value != sdb->max);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1540 }
19396
1586f6599a5b (svn r24297) -Codechange: Split DParam-setup for drawing setting values to a separate function.
frosch <frosch@openttd.org>
parents: 19395
diff changeset
1541 this->SetValueDParams(1, value);
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1542 DrawString(text_left, text_right, y, sdb->str, highlight ? TC_WHITE : TC_LIGHT_BLUE);
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1543 }
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
1544
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1545
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1546 /* == SettingsPage methods == */
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1547
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1548 /**
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1549 * Initialization of an entire setting page
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1550 * @param level Nesting level of this page (internal variable, do not provide a value for it when calling)
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1551 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1552 void SettingsPage::Init(byte level)
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1553 {
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1554 for (uint field = 0; field < this->num; field++) {
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1555 this->entries[field].Init(level);
10660
13267d179635 (svn r14962) -Codechange: add the concept of patch entries and patch (sub) pages
rubidium <rubidium@openttd.org>
parents: 10659
diff changeset
1556 }
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1557 }
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1558
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1559 /** Recursively close all folds of sub-pages */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1560 void SettingsPage::FoldAll()
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1561 {
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1562 for (uint field = 0; field < this->num; field++) {
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1563 this->entries[field].FoldAll();
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1564 }
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1565 }
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1566
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1567 /** Recursively open all folds of sub-pages */
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1568 void SettingsPage::UnFoldAll()
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1569 {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1570 for (uint field = 0; field < this->num; field++) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1571 this->entries[field].UnFoldAll();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1572 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1573 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1574
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1575 /**
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1576 * Recursively accumulate the folding state of the tree.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1577 * @param[in,out] all_folded Set to false, if one entry is not folded.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1578 * @param[in,out] all_unfolded Set to false, if one entry is folded.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1579 */
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1580 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1581 {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1582 for (uint field = 0; field < this->num; field++) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1583 this->entries[field].GetFoldingState(all_folded, all_unfolded);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1584 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1585 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1586
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1587 /**
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1588 * Update the filter state.
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1589 * @param filter String filter
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1590 * @param force_visible Whether to force all items visible, no matter what
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1591 * @param mode Additional way of filtering only changed settings on this screen (see restriction drop down box).
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1592 * @return true if item remains visible
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1593 */
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1594 bool SettingsPage::UpdateFilterState(StringFilter &filter, bool force_visible, RestrictionMode mode)
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1595 {
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1596 bool visible = false;
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1597 bool first_visible = true;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1598 for (int field = this->num - 1; field >= 0; field--) {
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1599 visible |= this->entries[field].UpdateFilterState(filter, force_visible, mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1600 this->entries[field].SetLastField(first_visible);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1601 if (visible && first_visible) first_visible = false;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1602 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1603 return visible;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1604 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1605
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1606
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1607 /**
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1608 * Check whether an entry is visible and not folded or filtered away.
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1609 * Note: This does not consider the scrolling range; it might still require scrolling ot make the setting really visible.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1610 * @param item Entry to search for.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1611 * @return true if entry is visible.
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1612 */
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1613 bool SettingsPage::IsVisible(const SettingEntry *item) const
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1614 {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1615 for (uint field = 0; field < this->num; field++) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1616 if (this->entries[field].IsVisible(item)) return true;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1617 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1618 return false;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1619 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
1620
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1621 /** Return number of rows needed to display the whole page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1622 uint SettingsPage::Length() const
10662
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1623 {
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1624 uint length = 0;
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1625 for (uint field = 0; field < this->num; field++) {
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1626 length += this->entries[field].Length();
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1627 }
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1628 return length;
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1629 }
5186b62666d4 (svn r14964) -Codechange: hide the length of a patch page behind a function (Alberth)
rubidium <rubidium@openttd.org>
parents: 10661
diff changeset
1630
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1631 /**
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1632 * Find the setting entry at row number \a row_num
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1633 * @param row_num Index of entry to return
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1634 * @param cur_row Variable used for keeping track of the current row number. Should point to memory initialized to \c 0 when first called.
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1635 * @return The requested setting entry or \c NULL if it does not exist
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1636 */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1637 SettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row) const
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1638 {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1639 SettingEntry *pe = NULL;
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1640
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1641 for (uint field = 0; field < this->num; field++) {
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1642 pe = this->entries[field].FindEntry(row_num, cur_row);
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1643 if (pe != NULL) {
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1644 break;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1645 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1646 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1647 return pe;
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1648 }
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
1649
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1650 /**
19339
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1651 * Get the biggest height of the help texts, if the width is at least \a maxw. Help text gets wrapped if needed.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1652 * @param maxw Maximal width of a line help text.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1653 * @return Biggest height needed to display any help text of this (sub-)tree.
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1654 */
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1655 uint SettingsPage::GetMaxHelpHeight(int maxw)
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1656 {
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1657 uint biggest = 0;
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1658 for (uint field = 0; field < this->num; field++) {
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1659 biggest = max(biggest, this->entries[field].GetMaxHelpHeight(maxw));
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1660 }
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1661 return biggest;
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1662 }
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1663
0c8d1038613a (svn r24236) -Add: Add code to retrieve help strings from the setting tree and compute max height.
alberth <alberth@openttd.org>
parents: 19336
diff changeset
1664 /**
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1665 * Draw a selected part of the settings page.
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1666 *
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1667 * The scrollbar uses rows of the page, while the page data strucure is a tree of #SettingsPage and #SettingEntry objects.
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1668 * As a result, the drawing routing traverses the tree from top to bottom, counting rows in \a cur_row until it reaches \a first_row.
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1669 * Then it enables drawing rows while traversing until \a max_row is reached, at which point drawing is terminated.
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1670 *
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1671 * @param settings_ptr Pointer to current values of all settings
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1672 * @param left Left-most position in window/panel to start drawing of each setting row
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
1673 * @param right Right-most position in window/panel to draw at
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1674 * @param base_y Upper-most position in window/panel to start drawing of row number \a first_row
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1675 * @param first_row Number of first row to draw
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1676 * @param max_row Row-number to stop drawing (the row-number of the row below the last row to draw)
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1677 * @param cur_row Current row number (internal variable)
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1678 * @param parent_last Last-field booleans of parent page level (page level \e i sets bit \e i to 1 if it is its last field)
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1679 * @param selected Selected entry by the user.
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1680 * @return Row number of the next row to draw
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1681 */
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1682 uint SettingsPage::Draw(GameSettings *settings_ptr, int left, int right, int base_y, uint first_row, uint max_row, SettingEntry *selected, uint cur_row, uint parent_last) const
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1683 {
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1684 if (cur_row >= max_row) return cur_row;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1685
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1686 for (uint i = 0; i < this->num; i++) {
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
1687 cur_row = this->entries[i].Draw(settings_ptr, left, right, base_y, first_row, max_row, cur_row, parent_last, selected);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1688 if (cur_row >= max_row) {
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1689 break;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1690 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1691 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1692 return cur_row;
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1693 }
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
1694
10659
b800143c7941 (svn r14961) -Update: remove the string from r14960 from the other languages too.
rubidium <rubidium@openttd.org>
parents: 10658
diff changeset
1695
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1696 static SettingEntry _settings_ui_display[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1697 SettingEntry("gui.date_format_in_default_names"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1698 SettingEntry("gui.population_in_label"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1699 SettingEntry("gui.measure_tooltip"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1700 SettingEntry("gui.loading_indicators"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1701 SettingEntry("gui.liveries"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1702 SettingEntry("gui.show_track_reservation"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1703 SettingEntry("gui.expenses_layout"),
14493
522dc4972f9f (svn r19064) -Feature: Allow to select different land colours for the smallmap (reworked by Alberth).
terkhen <terkhen@openttd.org>
parents: 14409
diff changeset
1704 SettingEntry("gui.smallmap_land_colour"),
18470
64ea4c57dcb9 (svn r23314) -Add: Add settings to restrict viewport zoom levels.
peter1138 <peter1138@openttd.org>
parents: 18469
diff changeset
1705 SettingEntry("gui.zoom_min"),
64ea4c57dcb9 (svn r23314) -Add: Add settings to restrict viewport zoom levels.
peter1138 <peter1138@openttd.org>
parents: 18469
diff changeset
1706 SettingEntry("gui.zoom_max"),
18650
7e084b7495c6 (svn r23497) -Add: Advanced display setting to control the linewidth in graphs. (ChillCore)
frosch <frosch@openttd.org>
parents: 18627
diff changeset
1707 SettingEntry("gui.graph_line_thickness"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1708 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1709 /** Display options sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1710 static SettingsPage _settings_ui_display_page = {_settings_ui_display, lengthof(_settings_ui_display)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1711
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1712 static SettingEntry _settings_ui_interaction[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1713 SettingEntry("gui.window_snap_radius"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1714 SettingEntry("gui.window_soft_limit"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1715 SettingEntry("gui.link_terraform_toolbar"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1716 SettingEntry("gui.prefer_teamchat"),
19681
c469aff45b20 (svn r24590) -Feature: More options for the auto-scroll setting. (adf88)
frosch <frosch@openttd.org>
parents: 19560
diff changeset
1717 SettingEntry("gui.auto_scrolling"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1718 SettingEntry("gui.reverse_scroll"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1719 SettingEntry("gui.smooth_scroll"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1720 SettingEntry("gui.left_mouse_btn_scrolling"),
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
1721 /* 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
1722 * 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
1723 * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1724 SettingEntry("gui.scrollwheel_scrolling"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1725 SettingEntry("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
1726 #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
1727 /* We might need to emulate a right mouse button on mac */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1728 SettingEntry("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
1729 #endif
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1730 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1731 /** Interaction sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1732 static SettingsPage _settings_ui_interaction_page = {_settings_ui_interaction, lengthof(_settings_ui_interaction)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1733
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1734 static SettingEntry _settings_ui[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1735 SettingEntry(&_settings_ui_display_page, STR_CONFIG_SETTING_DISPLAY_OPTIONS),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1736 SettingEntry(&_settings_ui_interaction_page, STR_CONFIG_SETTING_INTERACTION),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1737 SettingEntry("gui.show_finances"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1738 SettingEntry("gui.errmsg_duration"),
15495
9cffefe9d5db (svn r20144) -Feature: Allow to configure the delay of hover events, or to disable them completely.
terkhen <terkhen@openttd.org>
parents: 15405
diff changeset
1739 SettingEntry("gui.hover_delay"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1740 SettingEntry("gui.toolbar_pos"),
16463
4c4c9177f5eb (svn r21179) -Fix [FS#4201] (r69): if the main toolbar's location is configurable, why isn't the statusbar's location configurable?
rubidium <rubidium@openttd.org>
parents: 16448
diff changeset
1741 SettingEntry("gui.statusbar_pos"),
17645
a758139e348a (svn r22417) -Add: an advanced setting to specify the default palette to use for NewGRFs without action 14 palette information; this makes the default choice independent from the used base graphics and '-i' option.
frosch <frosch@openttd.org>
parents: 17579
diff changeset
1742 SettingEntry("gui.newgrf_default_palette"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1743 SettingEntry("gui.pause_on_newgame"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1744 SettingEntry("gui.advanced_vehicle_list"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1745 SettingEntry("gui.timetable_in_ticks"),
13760
a9c5c2c91d71 (svn r18285) -Feature: show the expected arrival/departure dates in the timetable window. Based on work by PhilSophus.
rubidium <rubidium@openttd.org>
parents: 13756
diff changeset
1746 SettingEntry("gui.timetable_arrival_departure"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1747 SettingEntry("gui.quick_goto"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1748 SettingEntry("gui.default_rail_type"),
17089
6e590e642890 (svn r21826) -Fix [FS#4007]: the expectations from the "always build infrastructure" setting name/description didn't match the behaviour
rubidium <rubidium@openttd.org>
parents: 16959
diff changeset
1749 SettingEntry("gui.disable_unsuitable_building"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1750 SettingEntry("gui.persistent_buildingtools"),
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11075
diff changeset
1751 SettingEntry("gui.coloured_news_year"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1752 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1753 /** Interface subpage */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1754 static SettingsPage _settings_ui_page = {_settings_ui, lengthof(_settings_ui)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1755
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1756 static SettingEntry _settings_construction_signals[] = {
19305
68ce0cd2cdc7 (svn r24194) -Change: Rename the 'signal_side' setting to 'train_signal_side', and add a third option while doing so.
frosch <frosch@openttd.org>
parents: 19240
diff changeset
1757 SettingEntry("construction.train_signal_side"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1758 SettingEntry("gui.enable_signal_gui"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1759 SettingEntry("gui.drag_signals_density"),
19240
6d61b53cde41 (svn r24129) -Feature [FS#3660]: Option to minimise signal distance when dragging over obstacles. (adf88)
michi_cc <michi_cc@openttd.org>
parents: 19169
diff changeset
1760 SettingEntry("gui.drag_signals_fixed_distance"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1761 SettingEntry("gui.semaphore_build_before"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1762 SettingEntry("gui.default_signal_type"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1763 SettingEntry("gui.cycle_signal_types"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1764 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1765 /** Signals subpage */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1766 static SettingsPage _settings_construction_signals_page = {_settings_construction_signals, lengthof(_settings_construction_signals)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1767
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1768 static SettingEntry _settings_construction[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1769 SettingEntry(&_settings_construction_signals_page, STR_CONFIG_SETTING_CONSTRUCTION_SIGNALS),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1770 SettingEntry("construction.build_on_slopes"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1771 SettingEntry("construction.autoslope"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1772 SettingEntry("construction.extra_dynamite"),
17220
026d5463e627 (svn r21959) -Change: replace longbridges with custom maximum bridge and tunnel length setting
rubidium <rubidium@openttd.org>
parents: 17219
diff changeset
1773 SettingEntry("construction.max_bridge_length"),
026d5463e627 (svn r21959) -Change: replace longbridges with custom maximum bridge and tunnel length setting
rubidium <rubidium@openttd.org>
parents: 17219
diff changeset
1774 SettingEntry("construction.max_tunnel_length"),
12200
abcb7c9c1d4d (svn r16614) -Codechange: Make the airport min/max available year a property of the Airport class.
yexo <yexo@openttd.org>
parents: 12067
diff changeset
1775 SettingEntry("station.never_expire_airports"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1776 SettingEntry("construction.freeform_edges"),
13983
aaf1fd51e6ac (svn r18522) -Feature: add the possibility to not make new tree tiles in-game
rubidium <rubidium@openttd.org>
parents: 13950
diff changeset
1777 SettingEntry("construction.extra_tree_placement"),
16694
2b17fca1c754 (svn r21426) -Change: introduce a setting for the types of commands that are allowed to be executed while paused
rubidium <rubidium@openttd.org>
parents: 16601
diff changeset
1778 SettingEntry("construction.command_pause_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
1779 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1780 /** Construction sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1781 static SettingsPage _settings_construction_page = {_settings_construction, lengthof(_settings_construction)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1782
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1783 static SettingEntry _settings_stations_cargo[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1784 SettingEntry("order.improved_load"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1785 SettingEntry("order.gradual_loading"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1786 SettingEntry("order.selectgoods"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1787 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1788 /** Cargo handling sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1789 static SettingsPage _settings_stations_cargo_page = {_settings_stations_cargo, lengthof(_settings_stations_cargo)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1790
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1791 static SettingEntry _settings_stations[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1792 SettingEntry(&_settings_stations_cargo_page, STR_CONFIG_SETTING_STATIONS_CARGOHANDLING),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1793 SettingEntry("station.adjacent_stations"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1794 SettingEntry("station.distant_join_stations"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1795 SettingEntry("station.station_spread"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1796 SettingEntry("economy.station_noise_level"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1797 SettingEntry("station.modified_catchment"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1798 SettingEntry("construction.road_stop_on_town_road"),
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 11217
diff changeset
1799 SettingEntry("construction.road_stop_on_competitor_road"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1800 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1801 /** Stations sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1802 static SettingsPage _settings_stations_page = {_settings_stations, lengthof(_settings_stations)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1803
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1804 static SettingEntry _settings_economy_towns[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1805 SettingEntry("economy.bribe"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1806 SettingEntry("economy.exclusive_rights"),
17234
08d6a07fe4ce (svn r21974) -Feature: Add a setting to enable/disable funding local road reconstruction.
terkhen <terkhen@openttd.org>
parents: 17223
diff changeset
1807 SettingEntry("economy.fund_roads"),
18469
3780c7d15df2 (svn r23313) -Fix: economy.fund_buildings was not shown in the GUI
truebrain <truebrain@openttd.org>
parents: 18431
diff changeset
1808 SettingEntry("economy.fund_buildings"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1809 SettingEntry("economy.town_layout"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1810 SettingEntry("economy.allow_town_roads"),
15405
fa04125ca60d (svn r20048) -Feature: Add a setting to forbid towns building level crossings.
michi_cc <michi_cc@openttd.org>
parents: 14902
diff changeset
1811 SettingEntry("economy.allow_town_level_crossings"),
13756
9f062af2f34a (svn r18281) -Feature: founding towns in-game (based on work by Belugas, TheJosh, GeekToo, Terkhen and others)
smatz <smatz@openttd.org>
parents: 13755
diff changeset
1812 SettingEntry("economy.found_town"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1813 SettingEntry("economy.mod_road_rebuild"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1814 SettingEntry("economy.town_growth_rate"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1815 SettingEntry("economy.larger_towns"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1816 SettingEntry("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
1817 };
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1818 /** Towns sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1819 static SettingsPage _settings_economy_towns_page = {_settings_economy_towns, lengthof(_settings_economy_towns)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1820
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1821 static SettingEntry _settings_economy_industries[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1822 SettingEntry("construction.raw_industry_construction"),
15971
4a7b8f4d73dc (svn r20659) -Feature: make the (flat) area around an industry configurable (Eddi|zuHause)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1823 SettingEntry("construction.industry_platform"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1824 SettingEntry("economy.multiple_industry_per_town"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1825 SettingEntry("game_creation.oil_refinery_limit"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1826 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1827 /** Industries sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1828 static SettingsPage _settings_economy_industries_page = {_settings_economy_industries, lengthof(_settings_economy_industries)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1829
18543
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1830 static SettingEntry _settings_economy_scripts[] = {
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1831 SettingEntry("script.script_max_opcode_till_suspend"),
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1832 };
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1833 /** Scripts sub-page */
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1834 static SettingsPage _settings_economy_scripts_page = {_settings_economy_scripts, lengthof(_settings_economy_scripts)};
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1835
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1836 static SettingEntry _settings_economy[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1837 SettingEntry(&_settings_economy_towns_page, STR_CONFIG_SETTING_ECONOMY_TOWNS),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1838 SettingEntry(&_settings_economy_industries_page, STR_CONFIG_SETTING_ECONOMY_INDUSTRIES),
18543
1ba866a592fd (svn r23387) -Fix: move ai.script_max_opcode_till_suspend to script.script_max_opcode_till_suspend
truebrain <truebrain@openttd.org>
parents: 18540
diff changeset
1839 SettingEntry(&_settings_economy_scripts_page, STR_CONFIG_SETTING_ECONOMY_SCRIPTS),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1840 SettingEntry("economy.inflation"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1841 SettingEntry("economy.smooth_economy"),
14155
96be446af436 (svn r18703) -Feature-ish: allow virtually paying a percentage of the leg profit in feeder chains. This to give the user a better chance to get a feeder system without "losses".
rubidium <rubidium@openttd.org>
parents: 14127
diff changeset
1842 SettingEntry("economy.feeder_payment_share"),
18570
bbdb2c13eb92 (svn r23415) -Feature: Infrastructure maintenance costs.
michi_cc <michi_cc@openttd.org>
parents: 18543
diff changeset
1843 SettingEntry("economy.infrastructure_maintenance"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1844 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1845 /** Economy sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1846 static SettingsPage _settings_economy_page = {_settings_economy, lengthof(_settings_economy)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1847
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1848 static SettingEntry _settings_ai_npc[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1849 SettingEntry("ai.ai_in_multiplayer"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1850 SettingEntry("ai.ai_disable_veh_train"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1851 SettingEntry("ai.ai_disable_veh_roadveh"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1852 SettingEntry("ai.ai_disable_veh_aircraft"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1853 SettingEntry("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
1854 };
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1855 /** Computer players sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1856 static SettingsPage _settings_ai_npc_page = {_settings_ai_npc, lengthof(_settings_ai_npc)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1857
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1858 static SettingEntry _settings_ai[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1859 SettingEntry(&_settings_ai_npc_page, STR_CONFIG_SETTING_AI_NPC),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1860 SettingEntry("economy.give_money"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1861 SettingEntry("economy.allow_shares"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1862 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1863 /** AI sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1864 static SettingsPage _settings_ai_page = {_settings_ai, lengthof(_settings_ai)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1865
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1866 static SettingEntry _settings_vehicles_routing[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1867 SettingEntry("pf.pathfinder_for_trains"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1868 SettingEntry("pf.forbid_90_deg"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1869 SettingEntry("pf.pathfinder_for_roadvehs"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1870 SettingEntry("pf.roadveh_queue"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1871 SettingEntry("pf.pathfinder_for_ships"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1872 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1873 /** Autorenew sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1874 static SettingsPage _settings_vehicles_routing_page = {_settings_vehicles_routing, lengthof(_settings_vehicles_routing)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1875
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1876 static SettingEntry _settings_vehicles_autorenew[] = {
11913
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11897
diff changeset
1877 SettingEntry("company.engine_renew"),
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11897
diff changeset
1878 SettingEntry("company.engine_renew_months"),
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11897
diff changeset
1879 SettingEntry("company.engine_renew_money"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1880 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1881 /** Autorenew sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1882 static SettingsPage _settings_vehicles_autorenew_page = {_settings_vehicles_autorenew, lengthof(_settings_vehicles_autorenew)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1883
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1884 static SettingEntry _settings_vehicles_servicing[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1885 SettingEntry("vehicle.servint_ispercent"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1886 SettingEntry("vehicle.servint_trains"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1887 SettingEntry("vehicle.servint_roadveh"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1888 SettingEntry("vehicle.servint_ships"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1889 SettingEntry("vehicle.servint_aircraft"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1890 SettingEntry("order.no_servicing_if_no_breakdowns"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1891 SettingEntry("order.serviceathelipad"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1892 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1893 /** Servicing sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1894 static SettingsPage _settings_vehicles_servicing_page = {_settings_vehicles_servicing, lengthof(_settings_vehicles_servicing)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1895
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1896 static SettingEntry _settings_vehicles_trains[] = {
17223
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17221
diff changeset
1897 SettingEntry("pf.reverse_at_signals"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1898 SettingEntry("vehicle.train_acceleration_model"),
14127
39a257893f4c (svn r18674) -Feature (FS#3459): Configurable slope steepness for trains from 0% to 10%, default is 3% as before (mostly by Terkhen)
peter1138 <peter1138@openttd.org>
parents: 14065
diff changeset
1899 SettingEntry("vehicle.train_slope_steepness"),
17221
edf36d7f3f86 (svn r21960) -Change: show the length of vehicles in tiles, instead of half tiles in the depot
rubidium <rubidium@openttd.org>
parents: 17220
diff changeset
1900 SettingEntry("vehicle.max_train_length"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1901 SettingEntry("vehicle.wagon_speed_limits"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1902 SettingEntry("vehicle.disable_elrails"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1903 SettingEntry("vehicle.freight_trains"),
11657
ff1084d0d8a0 (svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents: 11524
diff changeset
1904 SettingEntry("gui.stop_location"),
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1905 };
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1906 /** Trains sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1907 static SettingsPage _settings_vehicles_trains_page = {_settings_vehicles_trains, lengthof(_settings_vehicles_trains)};
10671
ec6b9e8e01aa (svn r14974) -Change: reorder/reorganise the entries of the settings window (Alberth)
rubidium <rubidium@openttd.org>
parents: 10670
diff changeset
1908
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1909 static SettingEntry _settings_vehicles[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1910 SettingEntry(&_settings_vehicles_routing_page, STR_CONFIG_SETTING_VEHICLES_ROUTING),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1911 SettingEntry(&_settings_vehicles_autorenew_page, STR_CONFIG_SETTING_VEHICLES_AUTORENEW),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1912 SettingEntry(&_settings_vehicles_servicing_page, STR_CONFIG_SETTING_VEHICLES_SERVICING),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1913 SettingEntry(&_settings_vehicles_trains_page, STR_CONFIG_SETTING_VEHICLES_TRAINS),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1914 SettingEntry("gui.new_nonstop"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1915 SettingEntry("gui.order_review_system"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1916 SettingEntry("gui.vehicle_income_warn"),
16772
975815b08336 (svn r21505) -Change: generalise the lost_train_warning setting to lost_vehicle_warning
rubidium <rubidium@openttd.org>
parents: 16734
diff changeset
1917 SettingEntry("gui.lost_vehicle_warn"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1918 SettingEntry("vehicle.never_expire_vehicles"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1919 SettingEntry("vehicle.max_trains"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1920 SettingEntry("vehicle.max_roadveh"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1921 SettingEntry("vehicle.max_aircraft"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1922 SettingEntry("vehicle.max_ships"),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1923 SettingEntry("vehicle.plane_speed"),
14385
5539b78ca7a4 (svn r18942) -Feature [FS#2678]: add a setting to reduce/disable aircraft crashes
yexo <yexo@openttd.org>
parents: 14350
diff changeset
1924 SettingEntry("vehicle.plane_crashes"),
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1925 SettingEntry("vehicle.dynamic_engines"),
14757
1cefc36bd6b2 (svn r19345) -Feature: Realistic acceleration for road vehicles.
terkhen <terkhen@openttd.org>
parents: 14645
diff changeset
1926 SettingEntry("vehicle.roadveh_acceleration_model"),
14758
bb75781f712c (svn r19346) -Feature: Configurable slope steepness for road vehicles from 0% to 10%, default is 7%.
terkhen <terkhen@openttd.org>
parents: 14757
diff changeset
1927 SettingEntry("vehicle.roadveh_slope_steepness"),
16505
0e4e40cd6128 (svn r21231) -Codechange: Generalize the naming of some settings and variables related to visual effects (Hirundo)
rubidium <rubidium@openttd.org>
parents: 16502
diff changeset
1928 SettingEntry("vehicle.smoke_amount"),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1929 };
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1930 /** Vehicles sub-page */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1931 static SettingsPage _settings_vehicles_page = {_settings_vehicles, lengthof(_settings_vehicles)};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1932
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1933 static SettingEntry _settings_main[] = {
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1934 SettingEntry(&_settings_ui_page, STR_CONFIG_SETTING_GUI),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1935 SettingEntry(&_settings_construction_page, STR_CONFIG_SETTING_CONSTRUCTION),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1936 SettingEntry(&_settings_vehicles_page, STR_CONFIG_SETTING_VEHICLES),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1937 SettingEntry(&_settings_stations_page, STR_CONFIG_SETTING_STATIONS),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1938 SettingEntry(&_settings_economy_page, STR_CONFIG_SETTING_ECONOMY),
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1939 SettingEntry(&_settings_ai_page, STR_CONFIG_SETTING_AI),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1940 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1941
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1942 /** Main page, holding all advanced settings */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1943 static SettingsPage _settings_main_page = {_settings_main, lengthof(_settings_main)};
10667
0a7a8b6d89b3 (svn r14970) -Change: move all (patch) settings to a single "page" (Alberth)
rubidium <rubidium@openttd.org>
parents: 10666
diff changeset
1944
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1945 static const StringID _game_settings_restrict_dropdown[] = {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1946 STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1947 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1948 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT_WO_LOCAL, // RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1949 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1950 };
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1951 assert_compile(lengthof(_game_settings_restrict_dropdown) == RM_END);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1952
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1953 struct GameSettingsWindow : QueryStringBaseWindow {
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1954 static const int SETTINGTREE_LEFT_OFFSET = 5; ///< Position of left edge of setting values
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1955 static const int SETTINGTREE_RIGHT_OFFSET = 5; ///< Position of right edge of setting values
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1956 static const int SETTINGTREE_TOP_OFFSET = 5; ///< Position of top edge of setting values
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1957 static const int SETTINGTREE_BOTTOM_OFFSET = 5; ///< Position of bottom edge of setting values
10540
ad93cc8a687f (svn r14797) -Codechange: replace even more magic numbers with constants (Alberth)
rubidium <rubidium@openttd.org>
parents: 10539
diff changeset
1958
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
1959 static GameSettings *settings_ptr; ///< Pointer to the game settings being displayed and modified.
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1960
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
1961 SettingEntry *valuewindow_entry; ///< If non-NULL, pointer to setting for which a value-entering window has been opened.
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
1962 SettingEntry *clicked_entry; ///< If non-NULL, pointer to a clicked numeric setting (with a depressed left or right button).
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
1963 SettingEntry *last_clicked; ///< If non-NULL, pointer to the last clicked setting.
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1964 SettingEntry *valuedropdown_entry; ///< If non-NULL, pointer to the value for which a dropdown window is currently opened.
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1965 bool closing_dropdown; ///< True, if the dropdown list is currently closing.
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1966
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1967 StringFilter string_filter; ///< Text filter for settings.
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
1968 bool manually_changed_folding; ///< Whether the user expanded/collapsed something manually.
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1969
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1970 RestrictionMode cur_restriction_mode; ///< Currently selected index of the drop down list for the restrict drop down.
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1971
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
1972 Scrollbar *vscroll;
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
1973
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
1974 GameSettingsWindow(const WindowDesc *desc) : QueryStringBaseWindow(50), cur_restriction_mode(RM_ALL)
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1975 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1976 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
1977
16959
55b2bec60c52 (svn r21695) -Codechange: add helper function to get the currently applicable GameSettings object
yexo <yexo@openttd.org>
parents: 16945
diff changeset
1978 settings_ptr = &GetGameSettings();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1979
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1980 /* 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
1981 if (first_time) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1982 _settings_main_page.Init();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1983 first_time = false;
10670
22ffe020ed5d (svn r14973) -Codechange: recursively fold subpages (Alberth)
rubidium <rubidium@openttd.org>
parents: 10667
diff changeset
1984 } else {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1985 _settings_main_page.FoldAll(); // Close all sub-pages
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
1986 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1987
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1988 this->valuewindow_entry = NULL; // No setting entry for which a entry window is opened
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
1989 this->clicked_entry = NULL; // No numeric setting buttons are depressed
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
1990 this->last_clicked = NULL;
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1991 this->valuedropdown_entry = NULL;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
1992 this->closing_dropdown = false;
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
1993 this->manually_changed_folding = false;
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1994
15779
9ad2843db6f4 (svn r20453) -Codechange: Remove direct accesses to Window::hscroll, vscroll and vscroll2.
frosch <frosch@openttd.org>
parents: 15778
diff changeset
1995 this->CreateNestedTree(desc);
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
1996 this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
1997 this->FinishInitNested(desc, WN_GAME_OPTIONS_GAME_SETTINGS);
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
1998
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
1999 this->text.Initialize(this->edit_str_buf, this->edit_str_size);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2000 this->SetFocusedWidget(WID_GS_FILTER);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2001
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2002 this->InvalidateData();
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2003 }
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2004
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
2005 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2006 {
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2007 switch (widget) {
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2008 case WID_GS_OPTIONSPANEL:
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2009 resize->height = SETTING_HEIGHT = max(11, FONT_HEIGHT_NORMAL + 1);
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2010 resize->width = 1;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2011
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2012 size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2013 break;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2014
19508
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2015 case WID_GS_HELP_TEXT: {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2016 static const StringID setting_types[] = {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2017 STR_CONFIG_SETTING_TYPE_CLIENT,
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2018 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2019 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2020 };
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2021 for (uint i = 0; i < lengthof(setting_types); i++) {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2022 SetDParam(0, setting_types[i]);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2023 size->width = max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2024 }
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2025 size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
19397
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2026 max(size->height, _settings_main_page.GetMaxHelpHeight(size->width));
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2027 break;
19508
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2028 }
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2029
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2030 default:
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2031 break;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2032 }
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2033 }
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
2034
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2035 virtual void OnPaint()
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2036 {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2037 if (this->closing_dropdown) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2038 this->closing_dropdown = false;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2039 assert(this->valuedropdown_entry != NULL);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2040 this->valuedropdown_entry->SetButtons(0);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2041 this->valuedropdown_entry = NULL;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2042 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2043 this->DrawWidgets();
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2044 this->DrawEditBox(WID_GS_FILTER);
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2045 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2046
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2047 virtual void SetStringParameters(int widget) const
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2048 {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2049 switch (widget) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2050 case WID_GS_RESTRICT_DROPDOWN:
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2051 SetDParam(0, _game_settings_restrict_dropdown[this->cur_restriction_mode]);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2052 break;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2053 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2054 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2055
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2056 DropDownList *BuildDropDownList(int widget) const
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2057 {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2058 DropDownList *list = NULL;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2059 switch (widget) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2060 case WID_GS_RESTRICT_DROPDOWN:
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2061 list = new DropDownList();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2062
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2063 for (int mode = 0; mode != RM_END; mode++) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2064 /* If we are in adv. settings screen for the new game's settings,
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2065 * we don't want to allow comparing with new game's settings. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2066 bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2067
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2068 list->push_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2069 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2070 break;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2071 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2072 return list;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2073 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2074
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2075 virtual void DrawWidget(const Rect &r, int widget) const
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2076 {
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2077 switch (widget) {
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2078 case WID_GS_OPTIONSPANEL:
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2079 _settings_main_page.Draw(settings_ptr, r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, r.top + SETTINGTREE_TOP_OFFSET,
19342
4eee2a5ed3c3 (svn r24239) -Add: Highlight setting that has its help text displayed.
alberth <alberth@openttd.org>
parents: 19340
diff changeset
2080 this->vscroll->GetPosition(), this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->last_clicked);
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2081 break;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2082
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2083 case WID_GS_HELP_TEXT:
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2084 if (this->last_clicked != NULL) {
19397
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2085 const SettingDesc *sd = this->last_clicked->d.entry.setting;
19508
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2086
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2087 int y = r.top;
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2088 if (sd->desc.flags & SGF_PER_COMPANY) {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2089 SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2090 } else if (sd->save.conv & SLF_NOT_IN_SAVE) {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2091 SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2092 } else {
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2093 SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2094 }
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2095 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2096 y += FONT_HEIGHT_NORMAL;
6e3043fce1db (svn r24411) -Add [FS#5244-ish]: Display the a setting type in the adv. settings description which explains the scope of changes to a particular setting.
frosch <frosch@openttd.org>
parents: 19413
diff changeset
2097
19397
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2098 int32 default_value = ReadValue(&sd->desc.def, sd->save.conv);
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2099 this->last_clicked->SetValueDParams(0, default_value);
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2100 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2101 y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2102
0ca99082a623 (svn r24298) -Feature: Display default values for adv. settings in the settings description.
frosch <frosch@openttd.org>
parents: 19396
diff changeset
2103 DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2104 }
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2105 break;
13364
f52b5b6c607b (svn r17873) -Codechange: make the advanced settings window nested
rubidium <rubidium@openttd.org>
parents: 13344
diff changeset
2106
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2107 default:
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2108 break;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2109 }
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2110 }
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2111
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2112 /**
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2113 * Set the entry that should have its help text displayed, and mark the window dirty so it gets repainted.
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2114 * @param pe Setting to display help text of, use \c NULL to stop displaying help of the currently displayed setting.
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2115 */
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2116 void SetDisplayedHelpText(SettingEntry *pe)
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2117 {
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2118 if (this->last_clicked != pe) this->SetDirty();
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2119 this->last_clicked = pe;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2120 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2121
14409
1eaefde497fd (svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents: 14385
diff changeset
2122 virtual void OnClick(Point pt, int widget, int click_count)
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2123 {
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2124 switch (widget) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2125 case WID_GS_EXPAND_ALL:
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2126 this->manually_changed_folding = true;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2127 _settings_main_page.UnFoldAll();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2128 this->InvalidateData();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2129 break;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2130
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2131 case WID_GS_COLLAPSE_ALL:
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2132 this->manually_changed_folding = true;
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2133 _settings_main_page.FoldAll();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2134 this->InvalidateData();
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2135 break;
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2136
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2137 case WID_GS_RESTRICT_DROPDOWN: {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2138 DropDownList *list = this->BuildDropDownList(widget);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2139 if (list != NULL) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2140 ShowDropDownList(this, list, this->cur_restriction_mode, widget);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2141 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2142 }
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2143 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2144
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2145 if (widget != WID_GS_OPTIONSPANEL) 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
2146
19410
b326bdfc63d3 (svn r24313) -Fix: Some obiwans wrt. clicking on setting buttons.
frosch <frosch@openttd.org>
parents: 19408
diff changeset
2147 uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET);
15563
011c8bee59d1 (svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
alberth <alberth@openttd.org>
parents: 15495
diff changeset
2148 if (btn == INT_MAX) return;
10664
5316fadc3fbd (svn r14966) -Codechange: simplify and generalise finding patch entries (Alberth)
rubidium <rubidium@openttd.org>
parents: 10663
diff changeset
2149
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2150 uint cur_row = 0;
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2151 SettingEntry *pe = _settings_main_page.FindEntry(btn, &cur_row);
10666
eacae31e4fe5 (svn r14969) -Codechange: make drawing trees possible (Alberth)
rubidium <rubidium@openttd.org>
parents: 10665
diff changeset
2152
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2153 if (pe == NULL) return; // Clicked below the last setting of the page
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
2154
19410
b326bdfc63d3 (svn r24313) -Fix: Some obiwans wrt. clicking on setting buttons.
frosch <frosch@openttd.org>
parents: 19408
diff changeset
2155 int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (pe->level + 1) * LEVEL_WIDTH; // Shift x coordinate
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2156 if (x < 0) return; // Clicked left of the entry
10665
5f8de7b4f4af (svn r14967) -Codechange: split the drawing of the window into several smaller functions (Alberth)
rubidium <rubidium@openttd.org>
parents: 10664
diff changeset
2157
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2158 if ((pe->flags & SEF_KIND_MASK) == SEF_SUBTREE_KIND) {
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2159 this->SetDisplayedHelpText(NULL);
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2160 pe->d.sub.folded = !pe->d.sub.folded; // Flip 'folded'-ness of the sub-page
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2161
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2162 this->manually_changed_folding = true;
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2163
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2164 this->InvalidateData();
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2165 return;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2166 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2167
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2168 assert((pe->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2169 const SettingDesc *sd = pe->d.entry.setting;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2170
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2171 /* return if action is only active in network, or only settable by server */
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2172 if ((!(sd->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(sd->desc.flags & SGF_PER_COMPANY)) ||
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2173 ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) || ((sd->desc.flags & SGF_NO_NETWORK) && _networking)) {
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2174 this->SetDisplayedHelpText(pe);
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2175 return;
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2176 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2177
12022
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2178 const void *var = ResolveVariableAddress(settings_ptr, sd);
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2179 int32 value = (int32)ReadValue(var, sd->save.conv);
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2180
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2181 /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2182 if (x < SETTING_BUTTON_WIDTH && (sd->desc.flags & SGF_MULTISTRING)) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2183 const SettingDescBase *sdb = &sd->desc;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2184 this->SetDisplayedHelpText(pe);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2185
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2186 if (this->valuedropdown_entry == pe) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2187 /* unclick the dropdown */
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2188 HideDropDownMenu(this);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2189 this->closing_dropdown = false;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2190 this->valuedropdown_entry->SetButtons(0);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2191 this->valuedropdown_entry = NULL;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2192 } else {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2193 if (this->valuedropdown_entry != NULL) this->valuedropdown_entry->SetButtons(0);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2194 this->closing_dropdown = false;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2195
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2196 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2197 int rel_y = (pt.y - (int)wid->pos_y - SETTINGTREE_TOP_OFFSET) % wid->resize_y;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2198
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2199 Rect wi_rect;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2200 wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2201 wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2202 wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2203 wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2204
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2205 /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2206 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2207 this->valuedropdown_entry = pe;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2208 this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2209
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2210 DropDownList *list = new DropDownList();
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2211 for (int i = sdb->min; i <= (int)sdb->max; i++) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2212 list->push_back(new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false));
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2213 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2214
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2215 ShowDropDownListAt(this, list, value, -1, wi_rect, COLOUR_ORANGE, true);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2216 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2217 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2218 this->SetDirty();
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2219 } else if (x < SETTING_BUTTON_WIDTH) {
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2220 this->SetDisplayedHelpText(pe);
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2221 const SettingDescBase *sdb = &sd->desc;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2222 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
2223
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2224 switch (sdb->cmd) {
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2225 case SDT_BOOLX: value ^= 1; break;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2226 case SDT_ONEOFMANY:
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2227 case SDT_NUMX: {
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2228 /* Add a dynamic step-size to the scroller. In a maximum of
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2229 * 50-steps you should be able to get from min to max,
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2230 * unless specified otherwise in the 'interval' variable
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2231 * of the current setting. */
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2232 uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2233 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
2234
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2235 /* don't allow too fast scrolling */
18677
7077d1f6763b (svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
truebrain <truebrain@openttd.org>
parents: 18650
diff changeset
2236 if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2237 _left_button_clicked = false;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2238 return;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2239 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2240
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2241 /* Increase or decrease the value and clamp it to extremes */
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2242 if (x >= SETTING_BUTTON_WIDTH / 2) {
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2243 value += step;
12357
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2244 if (sdb->min < 0) {
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2245 assert((int32)sdb->max >= 0);
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2246 if (value > (int32)sdb->max) value = (int32)sdb->max;
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2247 } else {
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2248 if ((uint32)value > sdb->max) value = (int32)sdb->max;
8fe6b4cef297 (svn r16781) -Fix [FS#3026] (r16297): don't cast negative values to uints when the settings' range is "negative..positive".
rubidium <rubidium@openttd.org>
parents: 12272
diff changeset
2249 }
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2250 if (value < sdb->min) value = sdb->min; // skip between "disabled" and minimum
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2251 } else {
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2252 value -= step;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2253 if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2254 }
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2255
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2256 /* Set up scroller timeout for numeric values */
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2257 if (value != oldvalue) {
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2258 if (this->clicked_entry != NULL) { // Release previous buttons if any
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2259 this->clicked_entry->SetButtons(0);
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2260 }
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2261 this->clicked_entry = pe;
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2262 this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
18677
7077d1f6763b (svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
truebrain <truebrain@openttd.org>
parents: 18650
diff changeset
2263 this->SetTimeout();
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2264 _left_button_clicked = false;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2265 }
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
2266 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15563
diff changeset
2267 }
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2268
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2269 default: NOT_REACHED();
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2270 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2271
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2272 if (value != oldvalue) {
12022
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2273 if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2274 SetCompanySetting(pe->d.entry.index, value);
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2275 } else {
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2276 SetSettingValue(pe->d.entry.index, value);
6258c029db2d (svn r16429) -Change: Make the company settings behave like all others settings: the default set in the main menu / config file is now really the default for a new company, and changing the value in game will no longer change the default for new companies.
yexo <yexo@openttd.org>
parents: 11973
diff changeset
2277 }
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2278 this->SetDirty();
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2279 }
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2280 } else {
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2281 /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2282 if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2283 /* Show the correct currency-translated value */
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2284 if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2285
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2286 this->valuewindow_entry = pe;
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2287 SetDParam(0, value);
17579
105b4e4eb168 (svn r22343) -Change: Remove pixel limiter for query strings.
terkhen <terkhen@openttd.org>
parents: 17551
diff changeset
2288 ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
10674
142d8484c2d8 (svn r14978) -Codechange: simplify the control flow of the OnClick of the settings window
rubidium <rubidium@openttd.org>
parents: 10671
diff changeset
2289 }
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2290 this->SetDisplayedHelpText(pe);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2291 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2292 }
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
2293
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2294 virtual void OnTimeout()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2295 {
10661
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
2296 if (this->clicked_entry != NULL) { // On timeout, release any depressed buttons
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
2297 this->clicked_entry->SetButtons(0);
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
2298 this->clicked_entry = NULL;
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
2299 this->SetDirty();
ba3579a2b84f (svn r14963) -Codechange: remember what entry was clicked instead of the index (Alberth)
rubidium <rubidium@openttd.org>
parents: 10660
diff changeset
2300 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2301 }
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
2302
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2303 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
2304 {
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2305 /* The user pressed cancel */
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2306 if (str == NULL) return;
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2307
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2308 assert(this->valuewindow_entry != NULL);
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2309 assert((this->valuewindow_entry->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2310 const SettingDesc *sd = this->valuewindow_entry->d.entry.setting;
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2311
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2312 int32 value;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2313 if (!StrEmpty(str)) {
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2314 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
2315
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2316 /* 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
2317 if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2318 } else {
14350
1718b22a6aa8 (svn r18905) -Fix (r18902): Compile error on 64-bit with gcc
peter1138 <peter1138@openttd.org>
parents: 14347
diff changeset
2319 value = (int32)(size_t)sd->desc.def;
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2320 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2321
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2322 if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2323 SetCompanySetting(this->valuewindow_entry->d.entry.index, value);
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2324 } else {
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2325 SetSettingValue(this->valuewindow_entry->d.entry.index, value);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2326 }
14347
a3c6860ea115 (svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
rubidium <rubidium@openttd.org>
parents: 14330
diff changeset
2327 this->SetDirty();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2328 }
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
2329
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2330 virtual void OnDropdownSelect(int widget, int index)
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2331 {
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2332 if (widget == WID_GS_RESTRICT_DROPDOWN) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2333 this->cur_restriction_mode = (RestrictionMode)index;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2334 _settings_main_page.UpdateFilterState(string_filter, false, this->cur_restriction_mode);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2335 this->SetDirty();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2336 return;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2337 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2338
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2339 /* Deal with drop down boxes on the panel. */
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2340 assert(this->valuedropdown_entry != NULL);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2341 const SettingDesc *sd = this->valuedropdown_entry->d.entry.setting;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2342 assert(sd->desc.flags & SGF_MULTISTRING);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2343
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2344 if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2345 SetCompanySetting(this->valuedropdown_entry->d.entry.index, index);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2346 } else {
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2347 SetSettingValue(this->valuedropdown_entry->d.entry.index, index);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2348 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2349
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2350 this->SetDirty();
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2351 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2352
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2353 virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2354 {
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2355 if (widget == WID_GS_RESTRICT_DROPDOWN) {
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2356 /* Normally the default implementation of OnDropdownClose() takes care of
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2357 * a few things. We want that behaviour here too, but only for this one
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2358 * "normal" dropdown box. The special dropdown boxes added for every
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2359 * setting that needs one can't have this call. */
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2360 Window::OnDropdownClose(pt, widget, index, instant_close);
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2361
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2362 if (!this->manually_changed_folding) _settings_main_page.UnFoldAll();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2363
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2364 this->InvalidateData();
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2365 return;
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2366 }
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2367
19413
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2368 /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2369 * the same dropdown button was clicked again, and then not open the dropdown again.
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2370 * So, we only remember that it was closed, and process it on the next OnPaint, which is
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2371 * after OnClick. */
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2372 assert(this->valuedropdown_entry != NULL);
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2373 this->closing_dropdown = true;
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2374 this->SetDirty();
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2375 }
d72c54b8d36b (svn r24316) -Feature: Allow setting adv. settings with limited range using a dropdown list.
frosch <frosch@openttd.org>
parents: 19410
diff changeset
2376
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2377 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2378 {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2379 if (!gui_scope) return;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2380
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2381 _settings_main_page.UpdateFilterState(string_filter, false, this->cur_restriction_mode);
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2382
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2383 this->vscroll->SetCount(_settings_main_page.Length());
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2384
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2385 if (this->last_clicked != NULL && !_settings_main_page.IsVisible(this->last_clicked)) {
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2386 this->SetDisplayedHelpText(NULL);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2387 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2388
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2389 bool all_folded = true;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2390 bool all_unfolded = true;
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2391 _settings_main_page.GetFoldingState(all_folded, all_unfolded);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2392 this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2393 this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2394 }
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2395
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2396 virtual void OnMouseLoop()
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2397 {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2398 this->HandleEditBox(WID_GS_FILTER);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2399 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2400
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2401 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2402 {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2403 /* Handle editbox input */
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2404 EventState state = ES_NOT_HANDLED;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2405 if (this->HandleEditBoxKey(WID_GS_FILTER, key, keycode, state) == HEBR_EDITING) {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2406 this->OnOSKInput(WID_GS_FILTER);
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2407 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2408 return state;
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2409 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2410
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2411 virtual void OnOSKInput(int wid)
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2412 {
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2413 string_filter.SetFilterTerm(this->edit_str_buf);
19712
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2414 if (!string_filter.IsEmpty() && !this->manually_changed_folding) {
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2415 /* User never expanded/collapsed single pages and entered a filter term.
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2416 * Expand everything, to save weird expand clicks, */
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2417 _settings_main_page.UnFoldAll();
e1b57eff3699 (svn r24633) -Add: Autoexpand the adv. settings tree, if a filter term is entered immediately after opening the window without any manual expanding/collapsing.
frosch <frosch@openttd.org>
parents: 19711
diff changeset
2418 }
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2419 this->InvalidateData();
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2420 }
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2421
13344
04b02b2cfa2b (svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
rubidium <rubidium@openttd.org>
parents: 13281
diff changeset
2422 virtual void OnResize()
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
2423 {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2424 this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET);
10543
0667832b2888 (svn r14800) -Codechange: make the advanced settings window resizeable and scrollable (most by Alberth)
rubidium <rubidium@openttd.org>
parents: 10542
diff changeset
2425 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2426 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2427
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2428 GameSettings *GameSettingsWindow::settings_ptr = 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
2429
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2430 static const NWidgetPart _nested_settings_selection_widgets[] = {
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2431 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
2432 NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
2433 NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2434 EndContainer(),
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2435 NWidget(WWT_PANEL, COLOUR_MAUVE),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2436 NWidget(NWID_HORIZONTAL), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2437 SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
19718
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2438 NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_LABEL), SetDataTip(STR_CONFIG_SETTING_RESTRICT_LABEL, STR_NULL),
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2439 NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2440 EndContainer(),
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2441 NWidget(NWID_HORIZONTAL), SetPadding(0, 0, WD_TEXTPANEL_BOTTOM, 0),
bb4e1d9b4da9 (svn r24647) -Feature: add new filter option to the advanced settings window to show only changed settings (Eagle_rainbow)
yexo <yexo@openttd.org>
parents: 19712
diff changeset
2442 SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
19711
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2443 NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2444 NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2445 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2446 EndContainer(),
817b521c2b1a (svn r24632) -Feature: Add text filtering to advanced settings.
frosch <frosch@openttd.org>
parents: 19710
diff changeset
2447 EndContainer(),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2448 NWidget(NWID_HORIZONTAL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2449 NWidget(WWT_PANEL, COLOUR_MAUVE, WID_GS_OPTIONSPANEL), SetMinimalSize(400, 174), SetScrollbar(WID_GS_SCROLLBAR), EndContainer(),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2450 NWidget(NWID_VERTICAL),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2451 NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2452 EndContainer(),
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2453 EndContainer(),
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2454 NWidget(WWT_PANEL, COLOUR_MAUVE), SetMinimalSize(400, 40),
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2455 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2456 SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT),
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2457 NWidget(NWID_HORIZONTAL),
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2458 NWidget(WWT_PANEL, COLOUR_MAUVE),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2459 NWidget(NWID_HORIZONTAL),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2460 NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2461 NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2462 NWidget(NWID_SPACER, INVALID_COLOUR), SetFill(1, 1), SetResize(1, 0),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2463 EndContainer(),
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2464 EndContainer(),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
2465 NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2466 EndContainer(),
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2467 EndContainer(),
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2468 };
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2469
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
2470 static const WindowDesc _settings_selection_desc(
19340
3fff29896c69 (svn r24237) -Feature: Descriptions explaining the meaning of advanced settings.
alberth <alberth@openttd.org>
parents: 19339
diff changeset
2471 WDP_CENTER, 510, 450,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
2472 WC_GAME_OPTIONS, WC_NONE,
19710
426ee8a3f9cd (svn r24631) -Feature: Add buttons to expand/collapse all to advanced settings GUI.
frosch <frosch@openttd.org>
parents: 19681
diff changeset
2473 WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
2474 _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
2475 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2476
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
2477 /** Open advanced settings window. */
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2478 void ShowGameSettings()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2479 {
18753
8d2cdabac894 (svn r23601) -Fix: fix the conflict in window number
truebrain <truebrain@openttd.org>
parents: 18703
diff changeset
2480 DeleteWindowByClass(WC_GAME_OPTIONS);
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 11049
diff changeset
2481 new GameSettingsWindow(&_settings_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
2482 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2483
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2484
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2485 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2486 * 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
2487 * @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
2488 * @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
2489 * @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
2490 * @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
2491 * @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
2492 * @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
2493 */
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
2494 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
2495 {
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
2496 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
2497
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2498 DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH / 2 - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2499 DrawFrameRect(x + SETTING_BUTTON_WIDTH / 2, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
13665
d9309c7b84bf (svn r18189) -Codechange: remove some now unneeded strings
rubidium <rubidium@openttd.org>
parents: 13663
diff changeset
2500 DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2501 DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + SETTING_BUTTON_WIDTH / 2, y + WD_IMGBTN_TOP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2502
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2503 /* Grey out the buttons that aren't clickable */
16441
86fd9bcc9d2f (svn r21157) -Codechange: remove information about the text direction out of the language "list"
rubidium <rubidium@openttd.org>
parents: 16302
diff changeset
2504 bool rtl = _current_text_dir == TD_RTL;
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
2505 if (rtl ? !clickable_right : !clickable_left) {
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2506 GfxFillRect(x + 1, y, x + SETTING_BUTTON_WIDTH / 2 - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
2507 }
13672
24880b3f9d87 (svn r18197) -Codechange: make the advanced settings window RTL aware and more big font aware
rubidium <rubidium@openttd.org>
parents: 13670
diff changeset
2508 if (rtl ? !clickable_left : !clickable_right) {
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2509 GfxFillRect(x + SETTING_BUTTON_WIDTH / 2 + 1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
9872
c26adcd5367e (svn r14018) -Fix (r14017): Typos prevented compilation.
peter1138 <peter1138@openttd.org>
parents: 9871
diff changeset
2510 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2511 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2512
18908
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2513 /**
19408
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2514 * Draw a dropdown button.
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2515 * @param x the x position to draw
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2516 * @param y the y position to draw
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2517 * @param button_colour the colour of the button
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2518 * @param state true = lowered
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2519 * @param clickable is the button clickable?
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2520 */
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2521 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2522 {
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2523 static const char *DOWNARROW = "\xEE\x8A\xAA";
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2524
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2525 int colour = _colour_gradient[button_colour][2];
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2526
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2527 DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, state ? FR_LOWERED : FR_NONE);
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2528 DrawString(x + (state ? 1 : 0), x + SETTING_BUTTON_WIDTH - (state ? 0 : 1), y + (state ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2529
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2530 if (!clickable) {
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2531 GfxFillRect(x + 1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2532 }
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2533 }
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2534
2d702686daaa (svn r24311) -Add: DrawDropDownButton() to draw dropdown buttons independent of actual widgets.
frosch <frosch@openttd.org>
parents: 19407
diff changeset
2535 /**
18908
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2536 * Draw a toggle button.
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2537 * @param x the x position to draw
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2538 * @param y the y position to draw
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2539 * @param state true = lowered
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2540 * @param clickable is the button clickable?
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2541 */
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2542 void DrawBoolButton(int x, int y, bool state, bool clickable)
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2543 {
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2544 static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
19407
e4f32df0a2b7 (svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
frosch <frosch@openttd.org>
parents: 19406
diff changeset
2545 DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
18908
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2546 }
b7744a321dc6 (svn r23757) -Codechange: Unify the drawing of toggle buttons for boolean settings.
frosch <frosch@openttd.org>
parents: 18891
diff changeset
2547
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2548 struct CustomCurrencyWindow : Window {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2549 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
2550
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2551 CustomCurrencyWindow(const WindowDesc *desc) : Window()
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2552 {
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2553 this->InitNested(desc);
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2554
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2555 SetButtonState();
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2556 }
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2557
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2558 void SetButtonState()
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2559 {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2560 this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2561 this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2562 this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2563 this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2564 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2565
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2566 virtual void SetStringParameters(int widget) const
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2567 {
13136
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2568 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2569 case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2570 case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2571 case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2572 case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2573 case WID_CC_YEAR:
13136
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2574 SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2575 SetDParam(1, _custom_currency.to_euro);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2576 break;
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2577
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2578 case WID_CC_PREVIEW:
13136
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2579 SetDParam(0, 10000);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2580 break;
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2581 }
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2582 }
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2583
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
2584 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2585 {
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2586 switch (widget) {
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2587 /* Set the appropriate width for the edit 'buttons' */
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2588 case WID_CC_SEPARATOR_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2589 case WID_CC_PREFIX_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2590 case WID_CC_SUFFIX_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2591 size->width = this->GetWidget<NWidgetBase>(WID_CC_RATE_DOWN)->smallest_x + this->GetWidget<NWidgetBase>(WID_CC_RATE_UP)->smallest_x;
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2592 break;
13136
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2593
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2594 /* Make sure the window is wide enough for the widest exchange rate */
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2595 case WID_CC_RATE:
13136
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2596 SetDParam(0, 1);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2597 SetDParam(1, INT32_MAX);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2598 *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
7db0723659c0 (svn r17641) -Codechange: remove the {N:...} that's not needed anymore since the currency window is nested.
rubidium <rubidium@openttd.org>
parents: 13135
diff changeset
2599 break;
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2600 }
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2601 }
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2602
14409
1eaefde497fd (svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents: 14385
diff changeset
2603 virtual void OnClick(Point pt, int widget, int click_count)
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2604 {
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2605 int line = 0;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2606 int len = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2607 StringID str = 0;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2608 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
2609
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2610 switch (widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2611 case WID_CC_RATE_DOWN:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2612 if (_custom_currency.rate > 1) _custom_currency.rate--;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2613 if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2614 this->EnableWidget(WID_CC_RATE_UP);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2615 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
2616
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2617 case WID_CC_RATE_UP:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2618 if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2619 if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2620 this->EnableWidget(WID_CC_RATE_DOWN);
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2621 break;
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2622
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2623 case WID_CC_RATE:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2624 SetDParam(0, _custom_currency.rate);
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12475
diff changeset
2625 str = STR_JUST_INT;
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2626 len = 5;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2627 line = WID_CC_RATE;
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2628 afilter = CS_NUMERAL;
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2629 break;
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2630
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2631 case WID_CC_SEPARATOR_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2632 case WID_CC_SEPARATOR:
11754
1b84d3b57f8b (svn r16144) -Fix (r16129): setting the custom digit grouping separator required to restart OpenTTD to take effect. Now also support non 1 ASCII character custom grouping separators.
rubidium <rubidium@openttd.org>
parents: 11752
diff changeset
2633 SetDParamStr(0, _custom_currency.separator);
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
2634 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
2635 len = 1;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2636 line = WID_CC_SEPARATOR;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2637 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
2638
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2639 case WID_CC_PREFIX_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2640 case WID_CC_PREFIX:
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
2641 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
2642 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
2643 len = 12;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2644 line = WID_CC_PREFIX;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2645 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
2646
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2647 case WID_CC_SUFFIX_EDIT:
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2648 case WID_CC_SUFFIX:
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
2649 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
2650 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
2651 len = 12;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2652 line = WID_CC_SUFFIX;
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2653 break;
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2654
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2655 case WID_CC_YEAR_DOWN:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2656 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2657 if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2658 this->EnableWidget(WID_CC_YEAR_UP);
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2659 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
2660
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2661 case WID_CC_YEAR_UP:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2662 _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2663 if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2664 this->EnableWidget(WID_CC_YEAR_DOWN);
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2665 break;
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2666
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2667 case WID_CC_YEAR:
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2668 SetDParam(0, _custom_currency.to_euro);
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12475
diff changeset
2669 str = STR_JUST_INT;
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2670 len = 7;
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2671 line = WID_CC_YEAR;
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2672 afilter = CS_NUMERAL;
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2673 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2674 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2675
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2676 if (len != 0) {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2677 this->query_widget = line;
17579
105b4e4eb168 (svn r22343) -Change: Remove pixel limiter for query strings.
terkhen <terkhen@openttd.org>
parents: 17551
diff changeset
2678 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 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
2679 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2680
18677
7077d1f6763b (svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
truebrain <truebrain@openttd.org>
parents: 18650
diff changeset
2681 this->SetTimeout();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2682 this->SetDirty();
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2683 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2684
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2685 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
2686 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2687 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
2688
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2689 switch (this->query_widget) {
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2690 case WID_CC_RATE:
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
2691 _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
2692 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2693
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2694 case WID_CC_SEPARATOR: // Thousands seperator
11754
1b84d3b57f8b (svn r16144) -Fix (r16129): setting the custom digit grouping separator required to restart OpenTTD to take effect. Now also support non 1 ASCII character custom grouping separators.
rubidium <rubidium@openttd.org>
parents: 11752
diff changeset
2695 strecpy(_custom_currency.separator, str, lastof(_custom_currency.separator));
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2696 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
2697
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2698 case WID_CC_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
2699 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
2700 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
2701
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2702 case WID_CC_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
2703 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
2704 break;
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2705
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2706 case WID_CC_YEAR: { // Year to switch to euro
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2707 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
2708
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2709 _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
2710 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
2711 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2712 }
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2713 MarkWholeScreenDirty();
11752
99ab03ebd58c (svn r16142) -Codechange: Use widgets in the custom currency window.
alberth <alberth@openttd.org>
parents: 11730
diff changeset
2714 SetButtonState();
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2715 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2716
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2717 virtual void OnTimeout()
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2718 {
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2719 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
2720 }
9246
1684bf12f0e0 (svn r13112) -Codechange: make classes of the patches and custom currency windows.
rubidium <rubidium@openttd.org>
parents: 9231
diff changeset
2721 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2722
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2723 static const NWidgetPart _nested_cust_currency_widgets[] = {
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2724 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
2725 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
2726 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2727 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
2728 NWidget(WWT_PANEL, COLOUR_GREY),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2729 NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(7, 3, 0),
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2730 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2731 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2732 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2733 NWidget(NWID_SPACER), SetMinimalSize(5, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2734 NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2735 EndContainer(),
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2736 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2737 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2738 NWidget(NWID_SPACER), SetMinimalSize(5, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2739 NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2740 EndContainer(),
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2741 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2742 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2743 NWidget(NWID_SPACER), SetMinimalSize(5, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2744 NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2745 EndContainer(),
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2746 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2747 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2748 NWidget(NWID_SPACER), SetMinimalSize(5, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2749 NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2750 EndContainer(),
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2751 NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2752 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2753 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2754 NWidget(NWID_SPACER), SetMinimalSize(5, 0),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2755 NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
13135
781c6205c0d7 (svn r17640) -Codechange: make the custom currency window nested
rubidium <rubidium@openttd.org>
parents: 13134
diff changeset
2756 EndContainer(),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2757 EndContainer(),
18703
b8177a6923bb (svn r23551) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents: 18680
diff changeset
2758 NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
2759 SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP), SetPadding(15, 1, 18, 2),
11762
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2760 EndContainer(),
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2761 };
6ee45c95e58e (svn r16152) -Codechange: Added nested widgets for advanced settings and for custom currency windows.
alberth <alberth@openttd.org>
parents: 11754
diff changeset
2762
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
2763 static const WindowDesc _cust_currency_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
2764 WDP_CENTER, 0, 0,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5688
diff changeset
2765 WC_CUSTOM_CURRENCY, WC_NONE,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
2766 WDF_UNCLICK_BUTTONS,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
2767 _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
2768 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2769
16734
634ab1038a43 (svn r21467) -Doc: Add a few doxygen comments to config file settings code.
alberth <alberth@openttd.org>
parents: 16694
diff changeset
2770 /** Open custom currency window. */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6012
diff changeset
2771 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
2772 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2773 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
2774 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
2775 }