annotate src/misc_gui.cpp @ 10499:45ca88a8de7d draft

(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
author rubidium <rubidium@openttd.org>
date Sun, 28 Dec 2008 14:37:19 +0000
parents b15aa92d60c9
children 53a8506c2079
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9082
diff changeset
3 /** @file misc_gui.cpp GUIs for a number of misc windows. */
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 6197
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "heightmap.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "debug.h"
6453
666fc3ef3174 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros <maedhros@openttd.org>
parents: 6350
diff changeset
9 #include "landscape.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
10 #include "newgrf.h"
7750
2df30880f88b (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
11 #include "newgrf_text.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
12 #include "saveload.h"
8108
4faab45e2603 (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
13 #include "tile_map.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
14 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
15 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
16 #include "station_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
17 #include "textbuf_gui.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
18 #include "viewport_func.h"
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
19 #include "gfx_func.h"
8785
2a8950a812dc (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents: 8748
diff changeset
20 #include "station_func.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
21 #include "command_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
22 #include "company_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
23 #include "company_base.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
24 #include "town.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25 #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
26 #include "variables.h"
8965
89de4625fe7d (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium <rubidium@openttd.org>
parents: 8916
diff changeset
27 #include "cheat_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
28 #include "train.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
29 #include "tgp.h"
6091
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
30 #include "cargotype.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
31 #include "company_manager_face.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8108
diff changeset
32 #include "strings_func.h"
10039
6301378f3e0f (svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium <rubidium@openttd.org>
parents: 9944
diff changeset
33 #include "fileio_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
34 #include "fios.h"
8119
b6ec923e9fa8 (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents: 8116
diff changeset
35 #include "tile_cmd.h"
8123
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8121
diff changeset
36 #include "zoom_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: 8123
diff changeset
37 #include "functions.h"
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8123
diff changeset
38 #include "window_func.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8139
diff changeset
39 #include "date_func.h"
8157
019833e42fda (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium <rubidium@openttd.org>
parents: 8152
diff changeset
40 #include "sound_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: 8208
diff changeset
41 #include "string_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
42 #include "company_gui.h"
8270
5613b863190d (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
43 #include "settings_type.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8785
diff changeset
44 #include "newgrf_cargo.h"
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8787
diff changeset
45 #include "rail_gui.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
46 #include "tilehighlight_func.h"
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
47 #include "querystring_gui.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
48 #include "company_base.h"
8119
b6ec923e9fa8 (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents: 8116
diff changeset
49
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
50 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
51 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
52
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 /* Variables to display file lists */
8149
ad7ddb6150dc (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents: 8144
diff changeset
54 SaveLoadDialogMode _saveload_mode;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 static bool _fios_path_changed;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58 static bool _savegame_sort_dirty;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 static const Widget _land_info_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
61 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
9790
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9781
diff changeset
62 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 299, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9781
diff changeset
63 { WWT_PANEL, RESIZE_BOTTOM, COLOUR_GREY, 0, 299, 14, 99, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 static const WindowDesc _land_info_desc = {
9790
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9781
diff changeset
68 WDP_AUTO, WDP_AUTO, 300, 100, 300, 100,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
69 WC_LAND_INFO, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 _land_info_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
74 class LandInfoWindow : public Window {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
75 enum {
9714
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
76 LAND_INFO_CENTERED_LINES = 12, ///< Up to 12 centered lines
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
77 LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
78 LAND_INFO_LINE_END,
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
79
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
80 LAND_INFO_LINE_BUFF_SIZE = 512,
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
81 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
83 public:
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
84 char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_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
85
9170
8c020e980b8c (svn r13033) -Fix [FS#2003](r13029): land info tool wasn't working
smatz <smatz@openttd.org>
parents: 9166
diff changeset
86 virtual void OnPaint()
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
87 {
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
88 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
90 uint y = 21;
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
91 for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
92 if (StrEmpty(this->landinfo_data[i])) break;
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
93
9790
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9781
diff changeset
94 DoDrawStringCentered(150, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING);
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
95 y += i == 0 ? 16 : 12;
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
96 }
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
97
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
98 y += 6;
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
99
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: 9572
diff changeset
100 if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) {
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: 9572
diff changeset
101 SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]);
9790
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9781
diff changeset
102 DrawStringMultiCenter(150, y, STR_JUST_RAW_STRING, this->width - 4);
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: 9572
diff changeset
103 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 }
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
105
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
106 LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
107 Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
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: 9407
diff changeset
108 Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
109
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
110 Money old_money = c->money;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
111 c->money = INT64_MAX;
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
112 CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
113 c->money = old_money;
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
114
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
115 /* Because build_date is not set yet in every TileDesc, we make sure it is empty */
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
116 TileDesc td;
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
117 AcceptedCargo ac;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118
9713
c94f47f48e76 (svn r13826) -Codechange: use 'INVALID_DATE' instead of '0' as placeholder in tile description
smatz <smatz@openttd.org>
parents: 9693
diff changeset
119 td.build_date = INVALID_DATE;
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
120
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
121 /* Most tiles have only one owner, but
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
122 * - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
123 * - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
124 */
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
125 td.owner_type[0] = STR_01A7_OWNER; // At least one owner is displayed, though it might be "N/A".
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
126 td.owner_type[1] = STR_NULL; // STR_NULL results in skipping the owner
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
127 td.owner_type[2] = STR_NULL;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
128 td.owner_type[3] = STR_NULL;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
129 td.owner[0] = OWNER_NONE;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
130 td.owner[1] = OWNER_NONE;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
131 td.owner[2] = OWNER_NONE;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
132 td.owner[3] = OWNER_NONE;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
133
9714
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
134 td.station_class = STR_NULL;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
135 td.station_name = STR_NULL;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
136
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
137 td.grf = NULL;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
138
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
139 GetAcceptedCargo(tile, ac);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
140 GetTileDesc(tile, &td);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
141
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
142 uint line_nr = 0;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
143
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
144 /* Tiletype */
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
145 SetDParam(0, td.dparam[0]);
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
146 GetString(this->landinfo_data[line_nr], td.str, lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
147 line_nr++;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
148
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
149 /* Up to four owners */
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
150 for (uint i = 0; i < 4; i++) {
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
151 if (td.owner_type[i] == STR_NULL) continue;
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
152
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
153 SetDParam(0, STR_01A6_N_A);
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
154 if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
155 GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
156 line_nr++;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
157 }
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
158
10497
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
159 /* Cost to clear/revenue when cleared */
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
160 StringID str = STR_01A4_COST_TO_CLEAR_N_A;
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
161 if (CmdSucceeded(costclear)) {
10497
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
162 Money cost = costclear.GetCost();
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
163 if (cost < 0) {
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
164 cost = -cost; // Negate negative cost to a positive revenue
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
165 str = STR_REVENUE_WHEN_CLEARED;
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
166 } else {
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
167 str = STR_01A5_COST_TO_CLEAR;
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
168 }
b15aa92d60c9 (svn r14752) -Fix [FS#2438]: revenue when clearing land would show up in red in the land info window as negative cost.
rubidium <rubidium@openttd.org>
parents: 10426
diff changeset
169 SetDParam(0, cost);
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
170 }
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
171 GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
172 line_nr++;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
174 /* Location */
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: 9572
diff changeset
175 char tmp[16];
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: 9572
diff changeset
176 snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
177 SetDParam(0, TileX(tile));
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
178 SetDParam(1, TileY(tile));
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
179 SetDParam(2, TileHeight(tile));
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: 9572
diff changeset
180 SetDParamStr(3, tmp);
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
181 GetString(this->landinfo_data[line_nr], STR_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
182 line_nr++;
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
183
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
184 /* Local authority */
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
185 SetDParam(0, STR_01A9_NONE);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
186 if (t != NULL && t->IsValid()) {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
187 SetDParam(0, STR_TOWN);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
188 SetDParam(1, t->index);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
189 }
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
190 GetString(this->landinfo_data[line_nr], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
191 line_nr++;
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
192
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
193 /* Build date */
9713
c94f47f48e76 (svn r13826) -Codechange: use 'INVALID_DATE' instead of '0' as placeholder in tile description
smatz <smatz@openttd.org>
parents: 9693
diff changeset
194 if (td.build_date != INVALID_DATE) {
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
195 SetDParam(0, td.build_date);
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
196 GetString(this->landinfo_data[line_nr], STR_BUILD_DATE, lastof(this->landinfo_data[line_nr]));
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
197 line_nr++;
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
198 }
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
199
9714
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
200 /* Station class */
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
201 if (td.station_class != STR_NULL) {
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
202 SetDParam(0, td.station_class);
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
203 GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_CLASS, lastof(this->landinfo_data[line_nr]));
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
204 line_nr++;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
205 }
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
206
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
207 /* Station type name */
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
208 if (td.station_name != STR_NULL) {
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
209 SetDParam(0, td.station_name);
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
210 GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_TYPE, lastof(this->landinfo_data[line_nr]));
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
211 line_nr++;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
212 }
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
213
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
214 /* NewGRF name */
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
215 if (td.grf != NULL) {
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
216 SetDParamStr(0, td.grf);
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
217 GetString(this->landinfo_data[line_nr], STR_TILEDESC_NEWGRF_NAME, lastof(this->landinfo_data[line_nr]));
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
218 line_nr++;
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
219 }
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
220
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
221 assert(line_nr < LAND_INFO_CENTERED_LINES);
cb9766ae1255 (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents: 9713
diff changeset
222
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
223 /* Mark last line empty */
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
224 this->landinfo_data[line_nr][0] = '\0';
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
225
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
226 /* Cargo acceptance is displayed in a extra multiline */
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
227 char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
228 bool found = false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
230 for (CargoID i = 0; i < NUM_CARGO; ++i) {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
231 if (ac[i] > 0) {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
232 /* Add a comma between each item. */
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
233 if (found) {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
234 *strp++ = ',';
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
235 *strp++ = ' ';
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
236 }
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
237 found = true;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
238
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
239 /* If the accepted value is less than 8, show it in 1/8:ths */
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
240 if (ac[i] < 8) {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
241 SetDParam(0, ac[i]);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
242 SetDParam(1, GetCargo(i)->name);
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
243 strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
244 } else {
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
245 strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
246 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
247 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
248 }
9322
258ab31489e0 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents: 9319
diff changeset
249 if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
250
9572
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
251 if (found) line_nr += 2;
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
252
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
253 if (line_nr > 6) ResizeWindow(this, 0, 12 * (line_nr - 6));
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
254
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
255 this->FindWindowPlacementAndResize(&_land_info_desc);
7c23a341f695 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz <smatz@openttd.org>
parents: 9441
diff changeset
256
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257 #if defined(_DEBUG)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
258 # define LANDINFOD_LEVEL 0
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259 #else
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
260 # define LANDINFOD_LEVEL 1
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
261 #endif
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
262 DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
263 DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
264 DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
265 DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
266 DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
267 DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
268 DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
269 DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _m[tile].m6);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
270 DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271 #undef LANDINFOD_LEVEL
9155
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
272 }
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
273 };
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
274
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
275 static void Place_LandInfo(TileIndex tile)
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
276 {
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
277 DeleteWindowById(WC_LAND_INFO, 0);
bb7dd4c8ed68 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents: 9153
diff changeset
278 new LandInfoWindow(tile);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
281 void PlaceLandBlockInfo()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 if (_cursor.sprite == SPR_CURSOR_QUERY) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
284 ResetObjectToPlace();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
285 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286 _place_proc = Place_LandInfo;
7889
1ed44baec4d2 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7859
diff changeset
287 SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
288 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
289 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
290
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291 static const Widget _about_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
292 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
293 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
294 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 419, 14, 271, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
295 { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 5, 414, 40, 245, STR_NULL, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
296 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
297 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
298
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
299 static const WindowDesc _about_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7321
diff changeset
300 WDP_CENTER, WDP_CENTER, 420, 272, 420, 272,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
301 WC_GAME_OPTIONS, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
302 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
303 _about_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
304 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
305
9227
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
306 struct AboutWindow : public Window {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
307 int scroll_height;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
308 uint16 counter;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
309
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
310 AboutWindow() : Window(&_about_desc)
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
311 {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
312 this->counter = 5;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
313 this->scroll_height = this->height - 40;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
314 this->FindWindowPlacementAndResize(&_about_desc);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
315 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
316
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
317 virtual void OnPaint()
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
318 {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
319 static const char *credits[] = {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
320 /*************************************************************************
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
321 * maximum length of string which fits in window -^*/
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
322 "Original design by Chris Sawyer",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
323 "Original graphics by Simon Foster",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
324 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
325 "The OpenTTD team (in alphabetical order):",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
326 " Jean-Francois Claeys (Belugas) - GUI, newindustries and more",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
327 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
328 " Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
9944
08df045bf757 (svn r14099) -Codechange: Welcome back, Celestar.
belugas <belugas@openttd.org>
parents: 9916
diff changeset
329 " Victor Fischer (Celestar) - Programming everywhere you need him to",
08df045bf757 (svn r14099) -Codechange: Welcome back, Celestar.
belugas <belugas@openttd.org>
parents: 9916
diff changeset
330 " Christoph Elsenhans (frosch) - General coding",
9227
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
331 " Loïc Guilloux (glx) - General coding",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
332 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
333 " Jonathan Coome (Maedhros) - High priest of the newGRF Temple",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
334 " Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
335 " Owen Rudge (orudge) - Forum host, OS/2 port",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
336 " Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
337 " Remko Bijker (Rubidium) - Lead coder and way more",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
338 " Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
339 " Zdenek Sojka (SmatZ) - Bug finder and fixer",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
340 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
341 "Inactive Developers:",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
342 " Tamás Faragó (Darkvater) - Ex-Lead coder",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
343 " Christoph Mallon (Tron) - Programmer, code correctness police",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
344 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
345 "Retired Developers:",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
346 " Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
347 " Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
348 " Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
349 " Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
350 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
351 "Special thanks go out to:",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
352 " Josef Drexler - For his great work on TTDPatch",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
353 " Marcin Grzegorczyk - For his documentation of TTD internals",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
354 " Petr Baudis (pasky) - Many patches, newGRF support",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
355 " Stefan Meißner (sign_de) - For his work on the console",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
356 " Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
357 " Cian Duffy (MYOB) - BeOS port / manual writing",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
358 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
359 " Richard Kempton (richK) - additional airports, initial TGP implementation",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
360 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
361 " Michael Blunck - Pre-Signals and Semaphores © 2003",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
362 " George - Canal/Lock graphics © 2003-2004",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
363 " David Dallaston - Tram tracks",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
364 " Marcin Grzegorczyk - Foundations for Tracks on Slopes",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
365 " All Translators - Who made OpenTTD a truly international game",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
366 " Bug Reporters - Without whom OpenTTD would still be full of bugs!",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
367 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
368 "",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
369 "And last but not least:",
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
370 " Chris Sawyer - For an amazing game!"
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
371 };
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
372
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
373 this->DrawWidgets();
9227
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
374
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
375 /* Show original copyright and revision version */
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
376 DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
377 DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
378
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
379 int y = this->scroll_height;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
380
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
381 /* Show all scrolling credits */
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
382 for (uint i = 0; i < lengthof(credits); i++) {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
383 if (y >= 50 && y < (this->height - 40)) {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
384 DoDrawString(credits[i], 10, y, TC_BLACK);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
385 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
386 y += 10;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
387 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
388
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
389 /* If the last text has scrolled start a new from the start */
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
390 if (y < 50) this->scroll_height = this->height - 40;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
391
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
392 DoDrawStringCentered(210, this->height - 25, "Website: http://www.openttd.org", TC_BLACK);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
393 DrawStringCentered(210, this->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
394 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
395
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
396 virtual void OnTick()
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
397 {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
398 if (--this->counter == 0) {
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
399 this->counter = 5;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
400 this->scroll_height--;
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
401 this->SetDirty();
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
402 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
403 }
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
404 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
406 void ShowAboutWindow()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
407 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408 DeleteWindowById(WC_GAME_OPTIONS, 0);
9227
35dbb597e9fd (svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents: 9226
diff changeset
409 new AboutWindow();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
412 static const Widget _errmsg_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
413 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
414 { WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
415 { WWT_PANEL, RESIZE_BOTTOM, COLOUR_RED, 0, 239, 14, 45, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
416 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
419 static const Widget _errmsg_face_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
420 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
421 { WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
422 { WWT_PANEL, RESIZE_BOTTOM, COLOUR_RED, 0, 333, 14, 136, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
426 struct ErrmsgWindow : public Window {
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
427 private:
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
428 uint duration;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
429 uint64 decode_params[20];
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
430 StringID message_1;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
431 StringID message_2;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
432 bool show_company_manager_face;
7750
2df30880f88b (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
433
9682
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
434 int y[2];
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
435
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
436 public:
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
437 ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_company_manager_face) :
9301
686aa69d2fcd (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium <rubidium@openttd.org>
parents: 9285
diff changeset
438 Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
439 show_company_manager_face(show_company_manager_face)
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
440 {
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: 9407
diff changeset
441 this->duration = _settings_client.gui.errmsg_duration;
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
442 CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
443 this->message_1 = msg1;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
444 this->message_2 = msg2;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
445 this->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
9682
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
446
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
447 SwitchToErrorRefStack();
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
448 RewindTextRefStack();
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
449
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
450 assert(msg2 != INVALID_STRING_ID);
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
451
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
452 int h2 = 3 + GetStringHeight(msg2, width - 2); // msg2 is printed first
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
453 int h1 = (msg1 == INVALID_STRING_ID) ? 0 : 3 + GetStringHeight(msg1, width - 2);
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
454
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
455 SwitchToNormalRefStack();
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
456
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
457 int h = 15 + h1 + h2;
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
458 height = max<int>(height, h);
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
459
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
460 if (msg1 == INVALID_STRING_ID) {
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
461 /* only 1 line will be printed */
9682
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
462 y[1] = (height - 15) / 2 + 15 - 5;
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
463 } else {
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
464 int over = (height - h) / 4;
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
465
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
466 y[1] = 15 + h2 / 2 + 1 - 5 + over;
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
467 y[0] = height - 3 - h1 / 2 - 5 - over;
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
468 }
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
469
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
470 this->FindWindowPlacementAndResize(width, height);
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
471 }
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
472
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
473 virtual void OnPaint()
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
474 {
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
475 CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
476 this->DrawWidgets();
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
477 CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
478
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
479 /* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages.
9272
22954a91c5aa (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium <rubidium@openttd.org>
parents: 9265
diff changeset
480 * If the message doesn't come from a NewGRF, it won't use the TTDP-style text ref. stack, so we won't hurt anything
22954a91c5aa (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium <rubidium@openttd.org>
parents: 9265
diff changeset
481 */
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
482 SwitchToErrorRefStack();
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
483 RewindTextRefStack();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
484
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
485 if (this->show_company_manager_face) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
486 const Company *c = GetCompany((CompanyID)GetDParamX(this->decode_params, 2));
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
487 DrawCompanyManagerFace(c->face, c->colour, 2, 16);
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
488 }
7750
2df30880f88b (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
489
9682
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
490 DrawStringMultiCenter(this->width - 120, y[1], this->message_2, this->width - 2);
ed50c006a790 (svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents: 9659
diff changeset
491 if (this->message_1 != INVALID_STRING_ID) DrawStringMultiCenter(this->width - 120, y[0], this->message_1, this->width - 2);
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
492
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
493 /* Switch back to the normal text ref. stack for NewGRF texts */
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
494 SwitchToNormalRefStack();
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
495 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
496
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
497 virtual void OnMouseLoop()
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
498 {
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
499 if (_right_button_down) delete this;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
500 }
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
501
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
502 virtual void OnHundredthTick()
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
503 {
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
504 if (--this->duration == 0) delete this;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
505 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
506
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
507 ~ErrmsgWindow()
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
508 {
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
509 SetRedErrorSquare(0);
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
510 extern StringID _switch_mode_errorstr;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
511 _switch_mode_errorstr = INVALID_STRING_ID;
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
512 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
513
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
514 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
515 {
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
516 if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
517 delete this;
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
518 return ES_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
519 }
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
520 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
521
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
522 void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
523 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
524 DeleteWindowById(WC_ERRMSG, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
525
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: 9407
diff changeset
526 if (!_settings_client.gui.errmsg_duration) 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
527
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
528 if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
529
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
530 Point pt;
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
531 const ViewPort *vp;
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
532
9265
746b863fafe6 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents: 9228
diff changeset
533 if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= 8) {
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
534 if ((x | y) != 0) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
535 pt = RemapCoords2(x, y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
536 vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
537
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 6197
diff changeset
538 /* move x pos to opposite corner */
6626
f940341a80f0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents: 6492
diff changeset
539 pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
540 pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - 260 : 20;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
541
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 6197
diff changeset
542 /* move y pos to opposite corner */
6626
f940341a80f0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents: 6492
diff changeset
543 pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->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
544 pt.y = (pt.y < (_screen.height >> 1)) ? _screen.height - 80 : 100;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
545
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
546 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
547 pt.x = (_screen.width - 240) >> 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
548 pt.y = (_screen.height - 46) >> 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
549 }
9272
22954a91c5aa (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium <rubidium@openttd.org>
parents: 9265
diff changeset
550 new ErrmsgWindow(pt, 240, 46, msg_1, msg_2, _errmsg_widgets, false);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
551 } else {
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
552 if ((x | y) != 0) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
553 pt = RemapCoords2(x, y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
554 vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
555 pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334 / 2), 0, _screen.width - 334);
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
556 pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137 / 2), 22, _screen.height - 137);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
557 } else {
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
558 pt.x = (_screen.width - 334) >> 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
559 pt.y = (_screen.height - 137) >> 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560 }
9272
22954a91c5aa (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium <rubidium@openttd.org>
parents: 9265
diff changeset
561 new ErrmsgWindow(pt, 334, 137, msg_1, msg_2, _errmsg_face_widgets, true);
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
563 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6953
diff changeset
565 void ShowEstimatedCostOrIncome(Money cost, int x, int y)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
567 StringID msg = STR_0805_ESTIMATED_COST;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
569 if (cost < 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570 cost = -cost;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
571 msg = STR_0807_ESTIMATED_INCOME;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572 }
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6998
diff changeset
573 SetDParam(0, cost);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
575 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6953
diff changeset
577 void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
578 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579 Point pt = RemapCoords(x,y,z);
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
580 StringID msg = STR_0801_COST;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 if (cost < 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583 cost = -cost;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584 msg = STR_0803_INCOME;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 }
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6998
diff changeset
586 SetDParam(0, cost);
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
587 AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
588 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
589
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6953
diff changeset
590 void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
591 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592 Point pt = RemapCoords(x,y,z);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
593
7002
fa75522e0249 (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents: 6998
diff changeset
594 SetDParam(0, cost);
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
595 AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
596 }
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
597
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
598 TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
599 {
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
600 Point pt = RemapCoords(x, y, z);
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
601
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
602 assert(string != STR_NULL);
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
603
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
604 SetDParam(0, percent);
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
605 return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
606 }
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
607
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
608 void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
609 {
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
610 assert(string != STR_NULL);
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
611
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
612 SetDParam(0, percent);
7014
d03670858cef (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight <truelight@openttd.org>
parents: 7007
diff changeset
613 UpdateTextEffect(te_id, string);
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
614 }
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
615
10176
71daf486081d (svn r14371) -Fix [FS#2313]: loading indicator didn't stay with the front engine when turning a train in a station.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
616 void HideFillingPercent(TextEffectID *te_id)
6998
13ea0d5f8acf (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight <truelight@openttd.org>
parents: 6991
diff changeset
617 {
10176
71daf486081d (svn r14371) -Fix [FS#2313]: loading indicator didn't stay with the front engine when turning a train in a station.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
618 if (*te_id == INVALID_TE_ID) return;
71daf486081d (svn r14371) -Fix [FS#2313]: loading indicator didn't stay with the front engine when turning a train in a station.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
619
71daf486081d (svn r14371) -Fix [FS#2313]: loading indicator didn't stay with the front engine when turning a train in a station.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
620 RemoveTextEffect(*te_id);
71daf486081d (svn r14371) -Fix [FS#2313]: loading indicator didn't stay with the front engine when turning a train in a station.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
621 *te_id = INVALID_TE_ID;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
622 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
623
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
624 static const Widget _tooltips_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
625 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 199, 0, 31, 0x0, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
626 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
627 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
628
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
629 struct TooltipsWindow : public Window
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
630 {
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
631 StringID string_id;
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
632 byte paramcount;
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
633 uint64 params[5];
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
634 bool use_left_mouse_button;
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
635
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
636 TooltipsWindow(int x, int y, int width, int height, const Widget *widget,
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
637 StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button) :
9301
686aa69d2fcd (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium <rubidium@openttd.org>
parents: 9285
diff changeset
638 Window(x, y, width, height, WC_TOOLTIPS, widget)
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
639 {
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
640 this->string_id = str;
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
641 assert(sizeof(this->params[0]) == sizeof(params[0]));
10201
6b20fe326959 (svn r14414) -Fix: replace instances of strncpy with strecpy as strncpy doesn't guarantee the resulting string is '\0'-terminated.
rubidium <rubidium@openttd.org>
parents: 10176
diff changeset
642 assert(paramcount <= lengthof(this->params));
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
643 memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
644 this->paramcount = paramcount;
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
645 this->use_left_mouse_button = use_left_mouse_button;
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
646
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
647 this->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
648 this->widget[0].right = width;
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
649 this->widget[0].bottom = height;
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
650
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
651 FindWindowPlacementAndResize(width, height);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
652 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
653
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
654 virtual void OnPaint()
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
655 {
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
656 GfxFillRect(0, 0, this->width - 1, this->height - 1, 0);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
657 GfxFillRect(1, 1, this->width - 2, this->height - 2, 0x44);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
658
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
659 for (uint arg = 0; arg < this->paramcount; arg++) {
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
660 SetDParam(arg, this->params[arg]);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
661 }
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
662 DrawStringMultiCenter((this->width >> 1), (this->height >> 1) - 5, this->string_id, this->width - 2);
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
663 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
664
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
665 virtual void OnMouseLoop()
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
666 {
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
667 /* We can show tooltips while dragging tools. These are shown as long as
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
668 * we are dragging the tool. Normal tooltips work with rmb */
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
669 if (this->use_left_mouse_button ? !_left_button_down : !_right_button_down) delete this;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
670 }
9186
c5c545191a71 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents: 9179
diff changeset
671 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
673 /** Shows a tooltip
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
674 * @param str String to be displayed
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
675 * @param paramcount number of params to deal with
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
676 * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
677 * @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
678 */
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
679 void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_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
680 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
681 DeleteWindowById(WC_TOOLTIPS, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
683 if (str == 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
684
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
685 for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
686 char buffer[512];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
687 GetString(buffer, str, lastof(buffer));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
688
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
689 Dimension br = GetStringBoundingBox(buffer);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
690 br.width += 6; br.height += 4; // increase slightly to have some space around the box
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
691
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
692 /* Cut tooltip length to 200 pixels max, wrap to new line if longer */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
693 if (br.width > 200) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
694 br.height += ((br.width - 4) / 176) * 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
695 br.width = 200;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
696 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
697
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
698 /* Correctly position the tooltip position, watch out for window and cursor size
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
699 * Clamp value to below main toolbar and above statusbar. If tooltip would
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
700 * go below window, flip it so it is shown above the cursor */
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
701 int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
702 if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
703 int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
704
9781
5ab8b1b156bb (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents: 9752
diff changeset
705 new TooltipsWindow(x, y, br.width, br.height, _tooltips_widgets, str, paramcount, params, use_left_mouse_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
706 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
707
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
708
8846
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
709 static int DrawStationCoverageText(const AcceptedCargo cargo,
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
710 int str_x, int str_y, StationCoverageType sct, bool supplies)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
711 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
712 bool first = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
713
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: 9572
diff changeset
714 char string[512];
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: 9572
diff changeset
715 char *b = InlineString(string, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
716
7241
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
717 for (CargoID i = 0; i < NUM_CARGO; i++) {
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: 9572
diff changeset
718 if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
7241
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
719 switch (sct) {
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
720 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
721 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
722 case SCT_ALL: break;
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
723 default: NOT_REACHED();
c40c1ad02f45 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium <rubidium@openttd.org>
parents: 7138
diff changeset
724 }
8916
45c397c7d804 (svn r12686) -Fix: MSVC signed/unsigned warning
glx <glx@openttd.org>
parents: 8846
diff changeset
725 if (cargo[i] >= (supplies ? 1U : 8U)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
726 if (first) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727 first = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
728 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
729 /* Add a comma if this is not the first item */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730 *b++ = ',';
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
731 *b++ = ' ';
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
732 }
6091
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
733 b = InlineString(b, GetCargo(i)->name);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
734 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
735 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
736
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
737 /* If first is still true then no cargo is accepted */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
738 if (first) b = InlineString(b, STR_00D0_NOTHING);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
739
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
740 *b = '\0';
8041
085c454f158b (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz <smatz@openttd.org>
parents: 8036
diff changeset
741
085c454f158b (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz <smatz@openttd.org>
parents: 8036
diff changeset
742 /* Make sure we detect any buffer overflow */
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: 9572
diff changeset
743 assert(b < endof(string));
8041
085c454f158b (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz <smatz@openttd.org>
parents: 8036
diff changeset
744
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: 9572
diff changeset
745 SetDParamStr(0, string);
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: 9572
diff changeset
746 return DrawStringMultiLine(str_x, str_y, STR_JUST_RAW_STRING, 144);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
747 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
748
8846
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
749 /**
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
750 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
751 * @param sx x position where the string is to be drawn
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
752 * @param sy y position where the string is to be drawn
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
753 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
754 * @param rad radius around selected tile(s) to be searched
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
755 * @param supplies if supplied cargos should be drawn, else accepted cargos
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
756 * @return Returns the y value below the string that was drawn
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
757 */
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
758 int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
7321
66202e2e042a (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
759 {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
760 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
8846
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
761 AcceptedCargo cargo;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
762 if (tile < MapSize()) {
8846
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
763 if (supplies) {
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
764 GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
765 } else {
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
766 GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
767 }
838e1d6a0321 (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8831
diff changeset
768 return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
769 }
8423
c9e5db937b31 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
770
c9e5db937b31 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
771 return sy;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
772 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
774 void CheckRedrawStationCoverage(const Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
775 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
776 if (_thd.dirty & 1) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
777 _thd.dirty &= ~1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
778 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
779 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
780 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
782 /* Delete a character at the caret position in a text buf.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
783 * If backspace is set, delete the character before the caret,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
784 * else delete the character after it. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785 static void DelChar(Textbuf *tb, bool backspace)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
786 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
787 WChar c;
6214
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
788 char *s = tb->buf + tb->caretpos;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
789
6214
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
790 if (backspace) s = Utf8PrevChar(s);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
791
9390
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
792 uint16 len = (uint16)Utf8Decode(&c, s);
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
793 uint width = GetCharacterWidth(FS_NORMAL, c);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
794
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
795 tb->width -= width;
6214
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
796 if (backspace) {
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
797 tb->caretpos -= len;
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
798 tb->caretxoffs -= width;
0716cb7258dd (svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater <Darkvater@openttd.org>
parents: 6211
diff changeset
799 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
801 /* Move the remaining characters over the marker */
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
802 memmove(s, s + len, tb->size - (s - tb->buf) - len);
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
803 tb->size -= len;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
805
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
806 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
807 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace'
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
808 * The character is delete from the position the caret is at
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
809 * @param tb Textbuf type to be changed
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
810 * @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
7372
694c7b595661 (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138 <peter1138@openttd.org>
parents: 7346
diff changeset
811 * @return Return true on successful change of Textbuf, or false otherwise
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
813 bool DeleteTextBufferChar(Textbuf *tb, int delmode)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
814 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
815 if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816 DelChar(tb, true);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817 return true;
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
818 } else if (delmode == WKC_DELETE && tb->caretpos < tb->size - 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
819 DelChar(tb, false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
820 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
821 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
822
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
823 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
824 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
825
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
826 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
827 * Delete every character in the textbuffer
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
828 * @param tb Textbuf buffer to be emptied
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
829 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
830 void DeleteTextBufferAll(Textbuf *tb)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
831 {
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
832 memset(tb->buf, 0, tb->maxsize);
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
833 tb->size = 1;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
834 tb->width = tb->caretpos = tb->caretxoffs = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
835 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
837 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
838 * Insert a character to a textbuffer. If maxwidth of the Textbuf is zero,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
839 * we don't care about the visual-length but only about the physical
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
840 * length of the string
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
841 * @param tb Textbuf type to be changed
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
842 * @param key Character to be inserted
7372
694c7b595661 (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138 <peter1138@openttd.org>
parents: 7346
diff changeset
843 * @return Return true on successful change of Textbuf, or false otherwise
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
844 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
845 bool InsertTextBufferChar(Textbuf *tb, WChar key)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
846 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
847 const byte charwidth = GetCharacterWidth(FS_NORMAL, key);
9390
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
848 uint16 len = (uint16)Utf8CharLen(key);
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
849 if (tb->size + len <= tb->maxsize && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) {
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
850 memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->size - tb->caretpos);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
851 Utf8Encode(tb->buf + tb->caretpos, key);
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
852 tb->size += len;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
853 tb->width += charwidth;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
855 tb->caretpos += len;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
856 tb->caretxoffs += charwidth;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
857 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
858 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
859 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
860 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
861
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
862 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
863 * Handle text navigation with arrow keys left/right.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
864 * This defines where the caret will blink and the next characer interaction will occur
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
865 * @param tb Textbuf type where navigation occurs
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
866 * @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
7372
694c7b595661 (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138 <peter1138@openttd.org>
parents: 7346
diff changeset
867 * @return Return true on successful change of Textbuf, or false otherwise
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
868 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
869 bool MoveTextBufferPos(Textbuf *tb, int navmode)
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 switch (navmode) {
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
872 case WKC_LEFT:
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
873 if (tb->caretpos != 0) {
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
874 WChar c;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
875 const char *s = Utf8PrevChar(tb->buf + tb->caretpos);
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
876 Utf8Decode(&c, s);
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
877 tb->caretpos = s - tb->buf; // -= (tb->buf + tb->caretpos - s)
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
878 tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
879
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
880 return true;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
881 }
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
882 break;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
883
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
884 case WKC_RIGHT:
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
885 if (tb->caretpos < tb->size - 1) {
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
886 WChar c;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
887
9390
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
888 tb->caretpos += (uint16)Utf8Decode(&c, tb->buf + tb->caretpos);
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
889 tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
890
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
891 return true;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
892 }
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
893 break;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
894
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
895 case WKC_HOME:
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
896 tb->caretpos = 0;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
897 tb->caretxoffs = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
898 return true;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
899
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
900 case WKC_END:
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
901 tb->caretpos = tb->size - 1;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
902 tb->caretxoffs = tb->width;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
903 return true;
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
904
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
905 default:
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
906 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
907 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
908
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
909 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
910 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
911
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
912 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
913 * Initialize the textbuffer by supplying it the buffer to write into
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
914 * and the maximum length of this buffer
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
915 * @param tb Textbuf type which is getting initialized
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
916 * @param buf the buffer that will be holding the data for input
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
917 * @param maxsize maximum size in bytes, including terminating '\0'
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
918 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
919 * cannot grow, even if maxsize would allow because there is space. Width
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
920 * of zero '0' means the buffer is only restricted by maxsize */
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
921 void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
922 {
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
923 assert(maxsize != 0);
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
924
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
925 tb->buf = buf;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
926 tb->maxsize = maxsize;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
927 tb->maxwidth = maxwidth;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
928 tb->caret = true;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
929 UpdateTextBufferSize(tb);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
930 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
931
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
932 /**
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
933 * Update Textbuf type with its actual physical character and screenlength
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
934 * Get the count of characters in the string as well as the width in pixels.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
935 * Useful when copying in a larger amount of text at once
6481
85a1a79387a2 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents: 6453
diff changeset
936 * @param tb Textbuf type which length is calculated
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
937 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
938 void UpdateTextBufferSize(Textbuf *tb)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
939 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
940 const char *buf = tb->buf;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
941
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
942 tb->width = 0;
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
943 tb->size = 1; // terminating zero
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
944
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
945 WChar c;
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
946 while ((c = Utf8Consume(&buf)) != '\0') {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
947 tb->width += GetCharacterWidth(FS_NORMAL, c);
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
948 tb->size += Utf8CharLen(c);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
950
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
951 assert(tb->size <= tb->maxsize);
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
952
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
953 tb->caretpos = tb->size - 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
954 tb->caretxoffs = tb->width;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
955 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
956
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957 bool HandleCaret(Textbuf *tb)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
959 /* caret changed? */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960 bool b = !!(_caret_timer & 0x20);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962 if (b != tb->caret) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
963 tb->caret = b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
964 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
965 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
966 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
967 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
968
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
969 HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
970 {
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
971 state = Window::ES_HANDLED;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
972
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
973 switch (keycode) {
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
974 case WKC_ESC: return HEBR_CANCEL;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
975
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
976 case WKC_RETURN: case WKC_NUM_ENTER: return HEBR_CONFIRM;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
977
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
978 case (WKC_CTRL | 'V'):
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
979 if (InsertTextBufferClipboard(&this->text)) w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
980 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
981
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
982 case (WKC_CTRL | 'U'):
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
983 DeleteTextBufferAll(&this->text);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
984 w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
985 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
986
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
987 case WKC_BACKSPACE: case WKC_DELETE:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
988 if (DeleteTextBufferChar(&this->text, keycode)) w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
989 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
990
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
991 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
992 if (MoveTextBufferPos(&this->text, keycode)) w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
993 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
994
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
995 default:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
996 if (IsValidChar(key, this->afilter)) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
997 if (InsertTextBufferChar(&this->text, key)) w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
998 } else { // key wasn't caught. Continue only if standard entry specified
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
999 state = (this->afilter == CS_ALPHANUMERAL) ? Window::ES_HANDLED : Window::ES_NOT_HANDLED;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1000 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1001 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1002
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
1003 return HEBR_EDITING;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1004 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1005
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1006 void QueryString::HandleEditBox(Window *w, int wid)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1007 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1008 if (HandleCaret(&this->text)) w->InvalidateWidget(wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1009 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1010
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1011 void QueryString::DrawEditBox(Window *w, int wid)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1012 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1013 const Widget *wi = &w->widget[wid];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014
8737
b62e473a9029 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8715
diff changeset
1015 assert((wi->type & WWT_MASK) == WWT_EDITBOX);
b62e473a9029 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8715
diff changeset
1016
5639
1b30f6b14a8a (svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater <Darkvater@openttd.org>
parents: 5596
diff changeset
1017 GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
1b30f6b14a8a (svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater <Darkvater@openttd.org>
parents: 5596
diff changeset
1018
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1019 DrawPixelInfo dpi;
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1020 int delta;
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1021
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1022 /* Limit the drawing of the string inside the widget boundaries */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1023 if (!FillDrawPixelInfo(&dpi,
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1024 wi->left + 4,
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1025 wi->top + 1,
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1026 wi->right - wi->left - 4,
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1027 wi->bottom - wi->top - 1)) {
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1028 return;
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1029 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1030
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1031 DrawPixelInfo *old_dpi = _cur_dpi;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1032 _cur_dpi = &dpi;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1033
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1034 /* We will take the current widget length as maximum width, with a small
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035 * space reserved at the end for the caret to show */
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1036 const Textbuf *tb = &this->text;
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1037
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038 delta = (wi->right - wi->left) - tb->width - 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1039 if (delta > 0) delta = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1040
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1042
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1043 DoDrawString(tb->buf, delta, 0, TC_YELLOW);
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1044 if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1045
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1046 _cur_dpi = old_dpi;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1047 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1049 int QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1050 {
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1051 return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1052 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1053
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1054 void QueryStringBaseWindow::HandleEditBox(int wid)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1055 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1056 this->QueryString::HandleEditBox(this, wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1057 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1058
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1059 void QueryStringBaseWindow::DrawEditBox(int wid)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1060 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1061 this->QueryString::DrawEditBox(this, wid);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1062 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1063
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1064 enum QueryStringWidgets {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1065 QUERY_STR_WIDGET_TEXT = 3,
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1066 QUERY_STR_WIDGET_DEFAULT,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1067 QUERY_STR_WIDGET_CANCEL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1068 QUERY_STR_WIDGET_OK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1069 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1070
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1071
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1072 struct QueryStringWindow : public QueryStringBaseWindow
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1073 {
9916
fa925e28f10e (svn r14069) -Fix: silence MSVC 64-bits compile warnings.
rubidium <rubidium@openttd.org>
parents: 9897
diff changeset
1074 QueryStringWindow(uint16 size, const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(size, desc)
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1075 {
9226
843042b3278b (svn r13092) -Fix (r13042): don't add a variable in a subclass when the parent class already have it
glx <glx@openttd.org>
parents: 9186
diff changeset
1076 this->parent = parent;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1077
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1078 this->FindWindowPlacementAndResize(desc);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1079 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1080
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1081 virtual void OnPaint()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1082 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1083 SetDParam(0, this->caption);
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
1084 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1085
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1086 this->DrawEditBox(QUERY_STR_WIDGET_TEXT);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1087 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1088
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1089 void OnOk()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1090 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1091 if (this->orig == NULL || strcmp(this->text.buf, this->orig) != 0) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1092 /* If the parent is NULL, the editbox is handled by general function
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1093 * HandleOnEditText */
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1094 if (this->parent != NULL) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1095 this->parent->OnQueryTextFinished(this->text.buf);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1096 } else {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1097 HandleOnEditText(this->text.buf);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1098 }
9228
68f81f013069 (svn r13094) -Fix: closing the QueryWindow would always send a 'query has been cancelled message' even when it was not cancelled causing joining passworded servers/companies to fail.
rubidium <rubidium@openttd.org>
parents: 9227
diff changeset
1099 this->handled = true;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1100 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1101 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1102
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1103 virtual void OnClick(Point pt, int widget)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1104 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1105 switch (widget) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1106 case QUERY_STR_WIDGET_TEXT:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1107 ShowOnScreenKeyboard(this, QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1108 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1109
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1110 case QUERY_STR_WIDGET_DEFAULT:
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1111 this->text.buf[0] = '\0';
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1112 /* Fallthrough */
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1113 case QUERY_STR_WIDGET_OK:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1114 this->OnOk();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1115 /* Fallthrough */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1116 case QUERY_STR_WIDGET_CANCEL:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1117 delete this;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1118 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1119 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1120 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1121
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1122 virtual void OnMouseLoop()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1123 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1124 this->HandleEditBox(QUERY_STR_WIDGET_TEXT);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1125 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1126
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1127 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1128 {
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1129 EventState state;
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1130 switch (this->HandleEditBoxKey(QUERY_STR_WIDGET_TEXT, key, keycode, state)) {
9399
617011acf06f (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents: 9394
diff changeset
1131 default: NOT_REACHED();
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
1132 case HEBR_EDITING: {
9399
617011acf06f (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents: 9394
diff changeset
1133 Window *osk = FindWindowById(WC_OSK, 0);
617011acf06f (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents: 9394
diff changeset
1134 if (osk != NULL && osk->parent == this) osk->OnInvalidateData();
617011acf06f (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents: 9394
diff changeset
1135 } break;
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
1136 case HEBR_CONFIRM: this->OnOk();
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1137 /* FALL THROUGH */
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
1138 case HEBR_CANCEL: delete this; break; // close window, abandon changes
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1139 }
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1140 return state;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1141 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1142
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1143 ~QueryStringWindow()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1144 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1145 if (!this->handled && this->parent != NULL) {
9393
aeff7240b474 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz <smatz@openttd.org>
parents: 9390
diff changeset
1146 Window *parent = this->parent;
aeff7240b474 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz <smatz@openttd.org>
parents: 9390
diff changeset
1147 this->parent = NULL; // so parent doesn't try to delete us again
aeff7240b474 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz <smatz@openttd.org>
parents: 9390
diff changeset
1148 parent->OnQueryTextFinished(NULL);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1149 }
9166
45b1388fe9ba (svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1150 }
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1151 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1152
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1153 static const Widget _query_string_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1154 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1155 { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 259, 0, 13, STR_012D, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1156 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 259, 14, 29, 0x0, STR_NULL},
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1157 { WWT_EDITBOX, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 27, 0x0, STR_NULL}, // QUERY_STR_WIDGET_TEXT
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1158 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 86, 30, 41, STR_DEFAULT, STR_NULL}, // QUERY_STR_WIDGET_DEFAULT
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1159 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 87, 172, 30, 41, STR_012E_CANCEL, STR_NULL}, // QUERY_STR_WIDGET_CANCEL
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1160 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 173, 259, 30, 41, STR_012F_OK, STR_NULL}, // QUERY_STR_WIDGET_OK
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1161 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1162 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1163
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1164 static const WindowDesc _query_string_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7321
diff changeset
1165 190, 219, 260, 42, 260, 42,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
1166 WC_QUERY_STRING, WC_NONE,
8019
9e262ce81acf (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas <belugas@openttd.org>
parents: 8018
diff changeset
1167 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_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
1168 _query_string_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1169 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1170
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1171 /** Show a query popup window with a textbox in it.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1172 * @param str StringID for the text shown in the textbox
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1173 * @param caption StringID of text shown in caption of querywindow
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1174 * @param maxsize maximum size in bytes (including terminating '\0')
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1175 * @param maxwidth maximum width in pixels allowed
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1176 * @param parent pointer to a Window that will handle the events (ok/cancel) of this
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9301
diff changeset
1177 * window. If NULL, results are handled by global function HandleOnEditText
10145
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 10039
diff changeset
1178 * @param afilter filters out unwanted character input
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 10039
diff changeset
1179 * @param flags various flags, @see QueryStringFlags
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 10039
diff changeset
1180 */
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1181 void ShowQueryString(StringID str, StringID caption, uint maxsize, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1182 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1183 DeleteWindowById(WC_QUERY_STRING, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1184 DeleteWindowById(WC_SAVELOAD, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1185
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1186 QueryStringWindow *w = new QueryStringWindow(maxsize, &_query_string_desc, parent);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1187
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1188 GetString(w->edit_str_buf, str, &w->edit_str_buf[maxsize - 1]);
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1189 w->edit_str_buf[maxsize - 1] = '\0';
9897
5b558ce6cb0e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
1190
10145
dbe302da93a8 (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz <smatz@openttd.org>
parents: 10039
diff changeset
1191 if ((flags & QSF_ACCEPT_UNCHANGED) == 0) w->orig = strdup(w->edit_str_buf);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1192
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1193 if ((flags & QSF_ENABLE_DEFAULT) == 0) {
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1194 /* without the "Default" button, make "Cancel" and "OK" buttons wider */
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1195 w->SetWidgetHiddenState(QUERY_STR_WIDGET_DEFAULT, true);
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1196 w->widget[QUERY_STR_WIDGET_CANCEL].left = 0;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1197 w->widget[QUERY_STR_WIDGET_CANCEL].right = w->width / 2 - 1;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1198 w->widget[QUERY_STR_WIDGET_OK].left = w->width / 2;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1199 w->widget[QUERY_STR_WIDGET_OK].right = w->width - 1;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1200 }
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1201
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
1202 w->LowerWidget(QUERY_STR_WIDGET_TEXT);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1203 w->caption = caption;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1204 w->afilter = afilter;
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1205 InitializeTextBuffer(&w->text, w->edit_str_buf, maxsize, maxwidth);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1206 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1207
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1208
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1209 enum QueryWidgets {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1210 QUERY_WIDGET_CAPTION = 1,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1211 QUERY_WIDGET_NO = 3,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1212 QUERY_WIDGET_YES
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1213 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1214
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1215 /**
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1216 * Window used for asking the user a YES/NO question.
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1217 */
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1218 struct QueryWindow : public Window {
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1219 QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1220 uint64 params[10]; ///< local copy of _decode_parameters
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1221 StringID message; ///< message shown for query window
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1222
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1223 QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1224 {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1225 if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1226 this->parent = parent;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1227 this->left = parent->left + (parent->width / 2) - (this->width / 2);
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1228 this->top = parent->top + (parent->height / 2) - (this->height / 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
1229
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1230 /* Create a backup of the variadic arguments to strings because it will be
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1231 * overridden pretty often. We will copy these back for drawing */
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1232 CopyOutDParam(this->params, 0, lengthof(this->params));
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1233 this->widget[QUERY_WIDGET_CAPTION].data = caption;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1234 this->message = message;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1235 this->proc = callback;
9178
708347596d9a (svn r13041) -Fix: calling a virtual function on a not fully constructed object is bound to cause errors.
rubidium <rubidium@openttd.org>
parents: 9176
diff changeset
1236
708347596d9a (svn r13041) -Fix: calling a virtual function on a not fully constructed object is bound to cause errors.
rubidium <rubidium@openttd.org>
parents: 9176
diff changeset
1237 this->FindWindowPlacementAndResize(desc);
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1238 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1239
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1240 ~QueryWindow()
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1241 {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1242 if (this->proc != NULL) this->proc(this->parent, false);
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1243 }
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1244
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1245 virtual void OnPaint()
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1246 {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1247 CopyInDParam(0, this->params, lengthof(this->params));
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
1248 this->DrawWidgets();
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1249 CopyInDParam(0, this->params, lengthof(this->params));
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1250
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1251 DrawStringMultiCenter(this->width / 2, (this->height / 2) - 10, this->message, this->width - 2);
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1252 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1253
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1254 virtual void OnClick(Point pt, int widget)
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1255 {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1256 switch (widget) {
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1257 case QUERY_WIDGET_YES: {
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1258 /* in the Generate New World window, clicking 'Yes' causes
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1259 * DeleteNonVitalWindows() to be called - we shouldn't be in a window then */
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1260 QueryCallbackProc *proc = this->proc;
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1261 Window *parent = this->parent;
9394
f62de1e2ea9a (svn r13305) -Fix (r13039): Confirmation window sent both yes and no answers instead of just yes.
peter1138 <peter1138@openttd.org>
parents: 9393
diff changeset
1262 /* Prevent the destructor calling the callback function */
f62de1e2ea9a (svn r13305) -Fix (r13039): Confirmation window sent both yes and no answers instead of just yes.
peter1138 <peter1138@openttd.org>
parents: 9393
diff changeset
1263 this->proc = NULL;
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1264 delete this;
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1265 if (proc != NULL) {
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1266 proc(parent, true);
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1267 proc = 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
1268 }
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1269 } break;
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1270 case QUERY_WIDGET_NO:
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1271 delete this;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1272 break;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1273 }
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1274 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1275
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1276 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1277 {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1278 /* ESC closes the window, Enter confirms the action */
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1279 switch (keycode) {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1280 case WKC_RETURN:
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1281 case WKC_NUM_ENTER:
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1282 if (this->proc != NULL) {
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1283 this->proc(this->parent, true);
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1284 this->proc = NULL;
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1285 }
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1286 /* Fallthrough */
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1287 case WKC_ESC:
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1288 delete this;
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1289 return ES_HANDLED;
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1290 }
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1291 return ES_NOT_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1292 }
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1293 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1294
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1295
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1296 static const Widget _query_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1297 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_RED, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1298 { WWT_CAPTION, RESIZE_NONE, COLOUR_RED, 11, 209, 0, 13, STR_NULL, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1299 { WWT_PANEL, RESIZE_NONE, COLOUR_RED, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1300 {WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 20, 90, 62, 73, STR_00C9_NO, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1301 {WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, 120, 190, 62, 73, STR_00C8_YES, STR_NULL},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1302 { WIDGETS_END },
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1303 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1304
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1305 static const WindowDesc _query_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7321
diff changeset
1306 WDP_CENTER, WDP_CENTER, 210, 82, 210, 82,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
1307 WC_CONFIRM_POPUP_QUERY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1308 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1309 _query_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1310 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1311
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1312 /** Show a modal confirmation window with standard 'yes' and 'no' buttons
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1313 * The window is aligned to the centre of its parent.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1314 * NOTE: You cannot use BindCString as parameter for this window!
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1315 * @param caption string shown as window caption
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1316 * @param message string that will be shown for the window
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1317 * @param parent pointer to parent window, if this pointer is NULL the parent becomes
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1318 * the main window WC_MAIN_WINDOW
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1319 * @param callback callback function pointer to set in the window descriptor
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1320 */
9319
7c3d6f855380 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents: 9317
diff changeset
1321 void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1322 {
9176
0f495f0a0c53 (svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents: 9170
diff changeset
1323 new QueryWindow(&_query_desc, caption, message, parent, callback);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1324 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1325
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1326
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1327 static const Widget _load_dialog_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1328 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1329 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1330 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1331 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1332 { WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 256, 26, 47, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1333 { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 256, 48, 153, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1334 { WWT_PUSHIMGBTN, RESIZE_LR, COLOUR_GREY, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1335 { WWT_INSET, RESIZE_RB, COLOUR_GREY, 2, 243, 50, 151, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1336 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 245, 256, 60, 141, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1337 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 245, 256, 142, 153, 0x0, STR_RESIZE_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
1338 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1339 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1340
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1341 static const Widget _save_dialog_widgets[] = {
9752
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1342 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1343 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1344 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1345 { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1346 { WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 256, 26, 47, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1347 { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 256, 48, 151, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1348 { WWT_PUSHIMGBTN, RESIZE_LR, COLOUR_GREY, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1349 { WWT_INSET, RESIZE_RB, COLOUR_GREY, 2, 243, 50, 150, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1350 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 245, 256, 60, 151, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1351 { WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 256, 152, 167, 0x0, STR_NULL},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1352 { WWT_EDITBOX, RESIZE_RTB, COLOUR_GREY, 2, 254, 154, 165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1353 { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 127, 168, 179, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1354 { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 128, 244, 168, 179, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING},
617fc1c2d1db (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas <belugas@openttd.org>
parents: 9714
diff changeset
1355 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 245, 256, 168, 179, 0x0, STR_RESIZE_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
1356 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1357 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1358
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 6197
diff changeset
1359 /* Colors for fios types */
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1360 const TextColour _fios_colors[] = {
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1361 TC_LIGHT_BLUE, TC_DARK_GREEN, TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1362 TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1363 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1364
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
1365 void BuildFileList()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1366 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1367 _fios_path_changed = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1368 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1369
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1370 switch (_saveload_mode) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1371 case SLD_NEW_GAME:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1372 case SLD_LOAD_SCENARIO:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1373 case SLD_SAVE_SCENARIO:
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1374 FiosGetScenarioList(_saveload_mode); 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
1375 case SLD_LOAD_HEIGHTMAP:
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1376 FiosGetHeightmapList(_saveload_mode); 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
1377
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1378 default: FiosGetSavegameList(_saveload_mode); 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
1379 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1380 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1381
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1382 static void DrawFiosTexts(uint maxw)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1383 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1384 static const char *path = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1385 static StringID str = STR_4006_UNABLE_TO_READ_DRIVE;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1386 static uint32 tot = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1387
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1388 if (_fios_path_changed) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1389 str = FiosGetDescText(&path, &tot);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1390 _fios_path_changed = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1391 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1392
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1393 if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1394 DrawString(2, 37, str, TC_FROMSTRING);
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7750
diff changeset
1395 DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1396 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1397
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
1398 static void MakeSortedSaveGameList()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1399 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1400 uint sort_start = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1401 uint sort_end = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1402
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1403 /* Directories are always above the files (FIOS_TYPE_DIR)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1404 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1405 * Only sort savegames/scenarios, not directories
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1406 */
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1407 for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1408 switch (item->type) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1409 case FIOS_TYPE_DIR: sort_start++; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1410 case FIOS_TYPE_PARENT: sort_start++; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1411 case FIOS_TYPE_DRIVE: sort_end++; break;
9031
9c6b04429f26 (svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents: 8973
diff changeset
1412 default: 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
1413 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1414 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1415
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1416 uint s_amount = _fios_items.Length() - sort_start - sort_end;
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1417 if (s_amount > 0) {
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1418 qsort(_fios_items.Get(sort_start), s_amount, sizeof(FiosItem), compare_FiosItems);
8819
98ec34b70edd (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1419 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1420 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1421
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
1422 extern void StartupEngines();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1423
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1424 struct SaveLoadWindow : public QueryStringBaseWindow {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1425 FiosItem o_dir;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1426
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1427 void GenerateFileName()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1428 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1429 /* Check if we are not a spectator who wants to generate a name..
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
1430 * Let's use the name of company #0 for now. */
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
1431 const Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1432
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10201
diff changeset
1433 SetDParam(0, c->index);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1434 SetDParam(1, _date);
9897
5b558ce6cb0e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
1435 GetString(this->edit_str_buf, STR_4004, &this->edit_str_buf[this->edit_str_size - 1]);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1436 SanitizeFilename(this->edit_str_buf);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1437 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1438
9897
5b558ce6cb0e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
1439 SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64, desc)
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1440 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1441 static const StringID saveload_captions[] = {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1442 STR_4001_LOAD_GAME,
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1443 STR_0298_LOAD_SCENARIO,
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1444 STR_4000_SAVE_GAME,
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1445 STR_0299_SAVE_SCENARIO,
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1446 STR_LOAD_HEIGHTMAP,
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1447 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1448
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1449 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1450
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1451 /* Use an array to define what will be the current file type being handled
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1452 * by current file mode */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1453 switch (mode) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1454 case SLD_SAVE_GAME: this->GenerateFileName(); break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1455 case SLD_SAVE_SCENARIO: strcpy(this->edit_str_buf, "UNNAMED"); break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1456 default: break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1457 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1458
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1459 assert((uint)mode < lengthof(saveload_captions));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1460
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1461 this->widget[1].data = saveload_captions[mode];
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1462 this->LowerWidget(7);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1463
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1464 this->afilter = CS_ALPHANUMERAL;
9897
5b558ce6cb0e (svn r14046) -Codechange: make the size of querystring "widgets" more configurable.
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
1465 InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 240);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1466
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1467 /* pause is only used in single-player, non-editor mode, non-menu mode. It
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1468 * will be unpaused in the WE_DESTROY event handler. */
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1469 if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10497
diff changeset
1470 if (_pause_game >= 0) DoCommandP(0, 1, 0, CMD_PAUSE);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1471 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1472
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1473 BuildFileList();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1474
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1475 ResetObjectToPlace();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1476
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1477 o_dir.type = FIOS_TYPE_DIRECT;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1478 switch (_saveload_mode) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1479 case SLD_SAVE_GAME:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1480 case SLD_LOAD_GAME:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1481 FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1482 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1483
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1484 case SLD_SAVE_SCENARIO:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1485 case SLD_LOAD_SCENARIO:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1486 FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1487 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
1488
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1489 case SLD_LOAD_HEIGHTMAP:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1490 FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1491 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
1492
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1493 default:
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: 10295
diff changeset
1494 strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1495 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1496
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1497 this->vscroll.cap = 10;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1498 this->resize.step_width = 2;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1499 this->resize.step_height = 10;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1500
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1501 this->FindWindowPlacementAndResize(desc);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1502 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1503
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1504 virtual ~SaveLoadWindow()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1505 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1506 /* pause is only used in single-player, non-editor mode, non menu mode */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1507 if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10497
diff changeset
1508 if (_pause_game >= 0) DoCommandP(0, 0, 0, CMD_PAUSE);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1509 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1510 FiosFreeSavegameList();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1511 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1512
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1513 virtual void OnPaint()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1514 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1515 int y;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1516
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1517 SetVScrollCount(this, _fios_items.Length());
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
1518 this->DrawWidgets();
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1519 DrawFiosTexts(this->width);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1520
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1521 if (_savegame_sort_dirty) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1522 _savegame_sort_dirty = false;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1523 MakeSortedSaveGameList();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1524 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1525
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1526 GfxFillRect(this->widget[7].left + 1, this->widget[7].top + 1, this->widget[7].right, this->widget[7].bottom, 0xD7);
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9272
diff changeset
1527 this->DrawSortButtonState(_savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1528
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1529 y = this->widget[7].top + 1;
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1530 for (uint pos = this->vscroll.pos; pos < _fios_items.Length(); pos++) {
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1531 const FiosItem *item = _fios_items.Get(pos);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1532
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1533 DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], this->width - 18);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1534 y += 10;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1535 if (y >= this->vscroll.cap * 10 + this->widget[7].top + 1) 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
1536 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1537
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1538 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1539 this->DrawEditBox(10);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1540 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1541 }
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1542
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1543 virtual void OnClick(Point pt, int widget)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1544 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1545 switch (widget) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1546 case 2: // Sort save names by name
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1547 _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1548 SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1549 _savegame_sort_dirty = true;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1550 this->SetDirty();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1551 break;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1552
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1553 case 3: // Sort save names by date
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1554 _savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1555 SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1556 _savegame_sort_dirty = true;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1557 this->SetDirty();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1558 break;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1559
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1560 case 6: // OpenTTD 'button', jumps to OpenTTD directory
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1561 FiosBrowseTo(&o_dir);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1562 this->SetDirty();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1563 BuildFileList();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1564 break;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1565
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1566 case 7: { // Click the listbox
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1567 int y = (pt.y - this->widget[widget].top - 1) / 10;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1568
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1569 if (y < 0 || (y += this->vscroll.pos) >= this->vscroll.count) return;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1570
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1571 const FiosItem *file = _fios_items.Get(y);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1572
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9413
diff changeset
1573 char *name = FiosBrowseTo(file);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1574 if (name != NULL) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1575 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1576 _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1577
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1578 SetFiosType(file->type);
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: 10295
diff changeset
1579 strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10295
diff changeset
1580 strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1581
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1582 delete this;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1583 } else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1584 SetFiosType(file->type);
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: 10295
diff changeset
1585 strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10295
diff changeset
1586 strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1587
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1588 delete this;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1589 ShowHeightmapLoad();
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1590 } else {
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1591 /* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10208
diff changeset
1592 ttd_strlcpy(this->text.buf, file->title, this->text.maxsize);
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1593 UpdateTextBufferSize(&this->text);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1594 this->InvalidateWidget(10);
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1595 }
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1596 } else {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1597 /* Changed directory, need repaint. */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1598 this->SetDirty();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1599 BuildFileList();
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1600 }
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1601 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
1602 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1603
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1604 case 10: // edit box
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1605 ShowOnScreenKeyboard(this, widget, 0, 0);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1606 break;
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1607
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1608 case 11: case 12: // Delete, Save game
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1609 break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1610 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1611 }
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1612
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1613 virtual void OnMouseLoop()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1614 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1615 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1616 this->HandleEditBox(10);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1617 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1618 }
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1619
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1620 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1621 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1622 if (keycode == WKC_ESC) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1623 delete this;
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1624 return ES_HANDLED;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1625 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1626
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1627 EventState state = ES_NOT_HANDLED;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1628 if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
10295
7ebf43f7c36b (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents: 10276
diff changeset
1629 this->HandleEditBoxKey(10, key, keycode, state) == HEBR_CONFIRM) {
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1630 this->HandleButtonClick(12);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1631 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1632
9285
3b3f13cb6db6 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
1633 return state;
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1634 }
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1635
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1636 virtual void OnTimeout()
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1637 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1638 /* This test protects against using widgets 11 and 12 which are only available
9693
cf5a441f1069 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz <smatz@openttd.org>
parents: 9682
diff changeset
1639 * in those two saveload mode */
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1640 if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) 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
1641
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1642 if (this->IsWidgetLowered(11)) { // Delete button clicked
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1643 if (!FiosDelete(this->text.buf)) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1644 ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1645 } else {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1646 BuildFileList();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1647 /* Reset file name to current date on successful delete */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1648 if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
8738
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1649 }
723631ab4868 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents: 8737
diff changeset
1650
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1651 UpdateTextBufferSize(&this->text);
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1652 this->SetDirty();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1653 } else if (this->IsWidgetLowered(12)) { // Save button clicked
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1654 _switch_mode = SM_SAVE;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1655 FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name));
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1656
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1657 /* In the editor set up the vehicle engines correctly (date might have changed) */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1658 if (_game_mode == GM_EDITOR) StartupEngines();
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1659 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1660 }
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1661
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1662 virtual void OnResize(Point new_size, Point delta)
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1663 {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1664 /* Widget 2 and 3 have to go with halve speed, make it so obiwan */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1665 uint diff = delta.x / 2;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1666 this->widget[2].right += diff;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1667 this->widget[3].left += diff;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1668 this->widget[3].right += delta.x;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1669
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1670 /* Same for widget 11 and 12 in save-dialog */
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1671 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1672 this->widget[11].right += diff;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1673 this->widget[12].left += diff;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1674 this->widget[12].right += delta.x;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1675 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1676
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1677 this->vscroll.cap += delta.y / 10;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1678 }
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1679 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1680
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1681 static const WindowDesc _load_dialog_desc = {
7346
4772500cfc44 (svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
1682 WDP_CENTER, WDP_CENTER, 257, 154, 257, 294,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
1683 WC_SAVELOAD, WC_NONE,
8019
9e262ce81acf (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas <belugas@openttd.org>
parents: 8018
diff changeset
1684 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1685 _load_dialog_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1686 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1687
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1688 static const WindowDesc _save_dialog_desc = {
7346
4772500cfc44 (svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
1689 WDP_CENTER, WDP_CENTER, 257, 180, 257, 320,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
1690 WC_SAVELOAD, WC_NONE,
8019
9e262ce81acf (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas <belugas@openttd.org>
parents: 8018
diff changeset
1691 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1692 _save_dialog_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1693 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1694
8152
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1695 /** These values are used to convert the file/operations mode into a corresponding file type.
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1696 * So each entry, as expressed by the related comment, is based on the enum */
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1697 static const FileType _file_modetotype[] = {
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1698 FT_SAVEGAME, ///< used for SLD_LOAD_GAME
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1699 FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1700 FT_SAVEGAME, ///< used for SLD_SAVE_GAME
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1701 FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1702 FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1703 FT_SAVEGAME, ///< SLD_NEW_GAME
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1704 };
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8149
diff changeset
1705
8149
ad7ddb6150dc (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents: 8144
diff changeset
1706 void ShowSaveLoadDialog(SaveLoadDialogMode mode)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1707 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1708 DeleteWindowById(WC_QUERY_STRING, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1709 DeleteWindowById(WC_SAVELOAD, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1710
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1711 const WindowDesc *sld;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1712 switch (mode) {
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1713 case SLD_SAVE_GAME:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1714 case SLD_SAVE_SCENARIO:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1715 sld = &_save_dialog_desc; break;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1716 default:
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1717 sld = &_load_dialog_desc; 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
1718 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1719
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1720 _saveload_mode = mode;
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1721 _file_to_saveload.filetype = _file_modetotype[mode];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1722
9179
3b7b689031d6 (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents: 9178
diff changeset
1723 new SaveLoadWindow(sld, mode);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1724 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1725
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6239
diff changeset
1726 void RedrawAutosave()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1727 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1728 SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1729 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1730
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1731 void SetFiosType(const byte fiostype)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1732 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1733 switch (fiostype) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1734 case FIOS_TYPE_FILE:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1735 case FIOS_TYPE_SCENARIO:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1736 _file_to_saveload.mode = SL_LOAD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1737 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1738
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1739 case FIOS_TYPE_OLDFILE:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1740 case FIOS_TYPE_OLD_SCENARIO:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1741 _file_to_saveload.mode = SL_OLD_LOAD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1742 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1743
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1744 #ifdef WITH_PNG
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1745 case FIOS_TYPE_PNG:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1746 _file_to_saveload.mode = SL_PNG;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1747 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1748 #endif /* WITH_PNG */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1749
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1750 case FIOS_TYPE_BMP:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1751 _file_to_saveload.mode = SL_BMP;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1752 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1753
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1754 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1755 _file_to_saveload.mode = SL_INVALID;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1756 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1757 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1758 }