Mercurial > hg > openttd
annotate src/misc_gui.cpp @ 14037:ca29deba0f1a draft
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
author | alberth <alberth@openttd.org> |
---|---|
date | Sun, 20 Dec 2009 20:08:39 +0000 |
parents | 3f141ce0d4ec |
children | 4eb2be463cc4 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12777
diff
changeset
|
9 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
9082
diff
changeset
|
10 /** @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
|
11 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
13 #include "openttd.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
|
14 #include "landscape.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
|
15 #include "newgrf_text.h" |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
10563
diff
changeset
|
16 #include "saveload/saveload.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
|
17 #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
|
18 #include "station_gui.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8214
diff
changeset
|
19 #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
|
20 #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
|
21 #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
|
22 #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
|
23 #include "company_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
|
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" |
11352
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
26 #include "network/network_content.h" |
10960
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10944
diff
changeset
|
27 #include "company_base.h" |
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10944
diff
changeset
|
28 #include "texteff.hpp" |
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
|
29 #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
|
30 #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
|
31 #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
|
32 #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
|
33 #include "fios.h" |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8121
diff
changeset
|
34 #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
|
35 #include "window_func.h" |
9127
428852b86d4d
(svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
36 #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
|
37 #include "querystring_gui.h" |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
38 |
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
|
39 #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
|
40 |
13201
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
41 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
42 /** |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
43 * Try to retrive the current clipboard contents. |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
44 * |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
45 * @note OS-specific funtion. |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
46 * @return True if some text could be retrived. |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
47 */ |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
48 bool GetClipboardContents(char *buffer, size_t buff_len); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
49 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
50 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
51 /* 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
|
52 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
|
53 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
54 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
55 static 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
|
56 static bool _savegame_sort_dirty; |
11230
4864c1e8957a
(svn r15584) -Codechange: Move several variables from variables.h to more appropriate headers.
yexo <yexo@openttd.org>
parents:
11225
diff
changeset
|
57 int _caret_timer; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
58 |
11429
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
59 /** Widgets for the land info window. */ |
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
60 enum LandInfoWidgets { |
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
61 LIW_BACKGROUND, ///< Background to draw on |
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
62 }; |
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
63 |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
64 static const NWidgetPart _nested_land_info_widgets[] = { |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
65 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
66 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
67 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
68 EndContainer(), |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
69 NWidget(WWT_PANEL, COLOUR_GREY, LIW_BACKGROUND), EndContainer(), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
70 }; |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
71 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
72 static const WindowDesc _land_info_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13792
diff
changeset
|
73 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
74 WC_LAND_INFO, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
75 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
76 _nested_land_info_widgets, lengthof(_nested_land_info_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
77 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
78 |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
79 class LandInfoWindow : public Window { |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
84 |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
85 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
|
86 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
88 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
|
89 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
|
90 |
9170
8c020e980b8c
(svn r13033) -Fix [FS#2003](r13029): land info tool wasn't working
smatz <smatz@openttd.org>
parents:
9166
diff
changeset
|
91 virtual void OnPaint() |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
92 { |
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
|
93 this->DrawWidgets(); |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
94 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
95 |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
96 virtual void DrawWidget(const Rect &r, int widget) const |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
97 { |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
98 if (widget != LIW_BACKGROUND) return; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
99 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
100 uint y = r.top + WD_TEXTPANEL_TOP; |
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
|
101 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
|
102 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
|
103 |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
104 DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_CENTER); |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
105 y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
106 if (i == 0) y += 4; |
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
|
107 } |
258ab31489e0
(svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents:
9319
diff
changeset
|
108 |
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
|
109 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
|
110 SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]); |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
111 DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_TEXTPANEL_BOTTOM, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER); |
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
|
112 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 } |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
114 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
115 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
116 { |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
117 if (widget != LIW_BACKGROUND) return; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
118 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
119 size->height = WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
120 for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) { |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
121 if (StrEmpty(this->landinfo_data[i])) break; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
122 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
123 uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
124 size->width = max(size->width, width); |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
125 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
126 size->height += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
127 if (i == 0) size->height += 4; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
128 } |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
129 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
130 if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) { |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
131 uint width = GetStringBoundingBox(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT; |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
132 size->width = max(size->width, min(300u, width)); |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
133 SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]); |
13683
42f82bcae40e
(svn r18208) -Fix [FS#3321]: in some cases the size of the land information window wasn't properly calculated
rubidium <rubidium@openttd.org>
parents:
13670
diff
changeset
|
134 size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT); |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
135 } |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
136 } |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
137 |
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
138 LandInfoWindow(TileIndex tile) : Window() { |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9407
diff
changeset
|
139 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
|
140 |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
141 /* 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
|
142 TileDesc td; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 |
9713
c94f47f48e76
(svn r13826) -Codechange: use 'INVALID_DATE' instead of '0' as placeholder in tile description
smatz <smatz@openttd.org>
parents:
9693
diff
changeset
|
144 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
|
145 |
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 /* 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
|
147 * - 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
|
148 * - 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
|
149 */ |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
150 td.owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER; // At least one owner is displayed, though it might be "N/A". |
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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 |
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
|
159 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
|
160 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
|
161 |
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
|
162 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
|
163 |
12261
c42d8d239142
(svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.
frosch <frosch@openttd.org>
parents:
12244
diff
changeset
|
164 CargoArray acceptance; |
12946
560c26f15688
(svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
smatz <smatz@openttd.org>
parents:
12927
diff
changeset
|
165 AddAcceptedCargo(tile, acceptance, NULL); |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
166 GetTileDesc(tile, &td); |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
167 |
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
|
168 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
|
169 |
258ab31489e0
(svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents:
9319
diff
changeset
|
170 /* Tiletype */ |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 |
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
|
175 /* 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
|
176 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
|
177 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
|
178 |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
179 SetDParam(0, STR_LAND_AREA_INFORMATION_OWNER_N_A); |
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
|
180 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
|
181 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
|
182 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
|
183 } |
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 |
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
|
185 /* Cost to clear/revenue when cleared */ |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
186 StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A; |
11955
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
187 Company *c = Company::GetIfValid(_local_company); |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
188 if (c != NULL) { |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
189 Money old_money = c->money; |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
190 c->money = INT64_MAX; |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
191 CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR); |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
192 c->money = old_money; |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
193 if (CmdSucceeded(costclear)) { |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
194 Money cost = costclear.GetCost(); |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
195 if (cost < 0) { |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
196 cost = -cost; // Negate negative cost to a positive revenue |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
197 str = STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED; |
11955
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
198 } else { |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
199 str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR; |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
200 } |
734fb1a3d241
(svn r16359) -Codechange: don't abuse company 0 when determining 'cost to clear land' in the LandInfoWindow
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
201 SetDParam(0, cost); |
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
|
202 } |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
203 } |
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
|
204 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
|
205 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
|
206 |
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
|
207 /* 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
|
208 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
|
209 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
|
210 SetDParam(0, TileX(tile)); |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
211 SetDParam(1, TileY(tile)); |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
212 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
|
213 SetDParamStr(3, tmp); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
214 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr])); |
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
|
215 line_nr++; |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
216 |
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
|
217 /* Local authority */ |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
218 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE); |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11955
diff
changeset
|
219 if (t != NULL) { |
12452
499dee1c27b6
(svn r16886) -Codechange: unify naming of some string IDs related to string codes and group them logically
rubidium <rubidium@openttd.org>
parents:
12415
diff
changeset
|
220 SetDParam(0, STR_TOWN_NAME); |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
221 SetDParam(1, t->index); |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
222 } |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
223 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY, lastof(this->landinfo_data[line_nr])); |
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
|
224 line_nr++; |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
225 |
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
|
226 /* 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
|
227 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
|
228 SetDParam(0, td.build_date); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
229 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_BUILD_DATE, lastof(this->landinfo_data[line_nr])); |
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
|
230 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
|
231 } |
258ab31489e0
(svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents:
9319
diff
changeset
|
232 |
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
|
233 /* 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
|
234 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
|
235 SetDParam(0, td.station_class); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
236 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_STATION_CLASS, lastof(this->landinfo_data[line_nr])); |
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
|
237 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
|
238 } |
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
|
239 |
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
|
240 /* 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
|
241 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
|
242 SetDParam(0, td.station_name); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
243 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_STATION_TYPE, lastof(this->landinfo_data[line_nr])); |
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
|
244 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
|
245 } |
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
|
246 |
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
|
247 /* 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
|
248 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
|
249 SetDParamStr(0, td.grf); |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
250 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_NEWGRF_NAME, lastof(this->landinfo_data[line_nr])); |
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
|
251 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
|
252 } |
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
|
253 |
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
|
254 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
|
255 |
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
|
256 /* 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
|
257 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
|
258 |
258ab31489e0
(svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents:
9319
diff
changeset
|
259 /* Cargo acceptance is displayed in a extra multiline */ |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
260 char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_LAND_AREA_INFORMATION_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
|
261 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
|
262 |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
263 for (CargoID i = 0; i < NUM_CARGO; ++i) { |
12261
c42d8d239142
(svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.
frosch <frosch@openttd.org>
parents:
12244
diff
changeset
|
264 if (acceptance[i] > 0) { |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
265 /* 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
|
266 if (found) { |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
267 *strp++ = ','; |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
268 *strp++ = ' '; |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
269 } |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
270 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
|
271 |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
272 /* If the accepted value is less than 8, show it in 1/8:ths */ |
12261
c42d8d239142
(svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.
frosch <frosch@openttd.org>
parents:
12244
diff
changeset
|
273 if (acceptance[i] < 8) { |
c42d8d239142
(svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.
frosch <frosch@openttd.org>
parents:
12244
diff
changeset
|
274 SetDParam(0, acceptance[i]); |
12415
6a77d1df56e2
(svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents:
12365
diff
changeset
|
275 SetDParam(1, CargoSpec::Get(i)->name); |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
276 strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, 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
|
277 } else { |
12415
6a77d1df56e2
(svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents:
12365
diff
changeset
|
278 strp = GetString(strp, CargoSpec::Get(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
|
279 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 } |
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
|
282 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
|
283 |
12834
f828651d0be0
(svn r17324) -Codechange: Land info window uses nested widget tree
Yexo <Yexo@openttd.org>
parents:
12821
diff
changeset
|
284 this->InitNested(&_land_info_desc); |
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
|
285 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 #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
|
287 # 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
|
288 #else |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
289 # 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
|
290 #endif |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 #undef LANDINFOD_LEVEL |
9155
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
301 } |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
302 }; |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
303 |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
304 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
|
305 { |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
306 DeleteWindowById(WC_LAND_INFO, 0); |
bb7dd4c8ed68
(svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium <rubidium@openttd.org>
parents:
9153
diff
changeset
|
307 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
|
308 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
310 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
|
311 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 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
|
313 ResetObjectToPlace(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
314 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
315 _place_proc = Place_LandInfo; |
11702
cdaad565efe5
(svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents:
11653
diff
changeset
|
316 SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_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
|
317 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 |
11429
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
320 /** Widgets for the land info window. */ |
8a62e44e06a1
(svn r15787) -Codechange: enumify the land info and about window widgets and use them.
rubidium <rubidium@openttd.org>
parents:
11427
diff
changeset
|
321 enum AboutWidgets { |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
322 AW_SCROLLING_TEXT, ///< The actually scrolling text |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
323 AW_WEBSITE, ///< URL of OpenTTD website |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
324 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
325 |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
326 static const NWidgetPart _nested_about_widgets[] = { |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
327 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
328 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
329 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_ABOUT_OPENTTD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
330 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
331 NWidget(WWT_PANEL, COLOUR_GREY), SetPIP(4, 2, 4), |
13797
5a6ed547542b
(svn r18323) -Fix [FS#3330]: credits were drawn on the border of the window
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
332 NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_ORIGINAL_COPYRIGHT, STR_NULL), |
5a6ed547542b
(svn r18323) -Fix [FS#3330]: credits were drawn on the border of the window
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
333 NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_VERSION, STR_NULL), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
334 NWidget(WWT_FRAME, COLOUR_GREY), SetPadding(0, 5, 1, 5), |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
335 NWidget(WWT_EMPTY, INVALID_COLOUR, AW_SCROLLING_TEXT), |
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
336 EndContainer(), |
13797
5a6ed547542b
(svn r18323) -Fix [FS#3330]: credits were drawn on the border of the window
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
337 NWidget(WWT_LABEL, COLOUR_GREY, AW_WEBSITE), SetDataTip(STR_BLACK_RAW_STRING, STR_NULL), |
5a6ed547542b
(svn r18323) -Fix [FS#3330]: credits were drawn on the border of the window
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
338 NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
339 EndContainer(), |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
340 }; |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
341 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
342 static const WindowDesc _about_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13792
diff
changeset
|
343 WDP_CENTER, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
344 WC_GAME_OPTIONS, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
345 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
346 _nested_about_widgets, lengthof(_nested_about_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
347 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 |
13096
e3e4c1648e0c
(svn r17596) -Codechange: constify some tables
smatz <smatz@openttd.org>
parents:
13072
diff
changeset
|
349 static const char * const _credits[] = { |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
350 "Original design by Chris Sawyer", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
351 "Original graphics by Simon Foster", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
352 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
353 "The OpenTTD team (in alphabetical order):", |
13587
f5704f568df1
(svn r18111) -Change: One more developer added to the history of OpenTTD.
alberth <alberth@openttd.org>
parents:
13580
diff
changeset
|
354 " Albert Hofkamp (Alberth) - GUI expert", |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
355 " Jean-Francois Claeys (Belugas) - GUI, newindustries and more", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
356 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
357 " Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
358 " Victor Fischer (Celestar) - Programming everywhere you need him to", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
359 " Christoph Elsenhans (frosch) - General coding", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
360 " Lo\xC3\xAF""c Guilloux (glx) - Windows Expert", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
361 " Michael Lutz (michi_cc) - Path based signals", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
362 " Owen Rudge (orudge) - Forum host, OS/2 port", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
363 " Peter Nelson (peter1138) - Spiritual descendant from newGRF gods", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
364 " Remko Bijker (Rubidium) - Lead coder and way more", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
365 " Zden\xC4\x9Bk Sojka (SmatZ) - Bug finder and fixer", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
366 " Thijs Marinussen (Yexo) - AI Framework", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
367 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
368 "Inactive Developers:", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
369 " Tam\xC3\xA1s Farag\xC3\xB3 (Darkvater) - Ex-Lead coder", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
370 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
371 " Jonathan Coome (Maedhros) - High priest of the NewGRF Temple", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
372 " Attila B\xC3\xA1n (MiHaMiX) - Developer WebTranslator 1 and 2", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
373 " Christoph Mallon (Tron) - Programmer, code correctness police", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
374 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
375 "Retired Developers:", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
376 " Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
377 " Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
378 " Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
379 " Benedikt Br\xC3\xBCggemeier (skidd13) - Bug fixer and code reworker", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
380 " Patric Stout (TrueLight) - Programmer (0.3 - pre0.7), sys op (active)", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
381 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
382 "Special thanks go out to:", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
383 " Josef Drexler - For his great work on TTDPatch", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
384 " Marcin Grzegorczyk - For his documentation of TTD internals", |
13063
d6196415e66a
(svn r17561) -Fix: diacritics was missing at few places
smatz <smatz@openttd.org>
parents:
13034
diff
changeset
|
385 " Petr Baudi\xC5\xA1 (pasky) - Many patches, newGRF support", |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
386 " Stefan Mei\xC3\x9Fner (sign_de) - For his work on the console", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
387 " Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
388 " Cian Duffy (MYOB) - BeOS port / manual writing", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
389 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
390 " Richard Kempton (richK) - additional airports, initial TGP implementation", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
391 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
392 " Alberto Demichelis - Squirrel scripting language \xC2\xA9 2003-2008", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
393 " Markus F.X.J. Oberhumer - (Mini)LZO for loading old savegames \xC2\xA9 1996-2008", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
394 " L. Peter Deutsch - MD5 implementation \xC2\xA9 1999, 2000, 2002", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
395 " Michael Blunck - Pre-Signals and Semaphores \xC2\xA9 2003", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
396 " George - Canal/Lock graphics \xC2\xA9 2003-2004", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
397 " David Dallaston - Tram tracks", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
398 " Marcin Grzegorczyk - Foundations for Tracks on Slopes", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
399 " All Translators - Who made OpenTTD a truly international game", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
400 " Bug Reporters - Without whom OpenTTD would still be full of bugs!", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
401 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
402 "", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
403 "And last but not least:", |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
404 " Chris Sawyer - For an amazing game!" |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
405 }; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
406 |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
407 struct AboutWindow : public Window { |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
408 int text_position; ///< The top of the scrolling text |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
409 byte counter; ///< Used to scroll the text every 5 ticks |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
410 int line_height; ///< The height of a single line |
12867
00a4b1fd0faf
(svn r17359) -Fix: put static before cv qualifier, some compilers complain about that
smatz <smatz@openttd.org>
parents:
12856
diff
changeset
|
411 static const int num_visible_lines = 19; ///< The number of lines visible simultaneously |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
412 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
413 AboutWindow() : Window() |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
414 { |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
415 this->InitNested(&_about_desc); |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
416 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
417 this->counter = 5; |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
418 this->text_position = this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->current_y; |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
419 } |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
420 |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
421 virtual void SetStringParameters(int widget) const |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
422 { |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
423 if (widget == AW_WEBSITE) SetDParamStr(0, "Website: http://www.openttd.org"); |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
424 } |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
425 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
426 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
427 { |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
428 if (widget != AW_SCROLLING_TEXT) return; |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
429 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
430 this->line_height = FONT_HEIGHT_NORMAL; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
431 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
432 Dimension d; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
433 d.height = this->line_height * num_visible_lines; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
434 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
435 d.width = 0; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
436 for (uint i = 0; i < lengthof(_credits); i++) { |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
437 d.width = max(d.width, GetStringBoundingBox(_credits[i]).width); |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
438 } |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
439 *size = maxdim(*size, d); |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
440 } |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
441 |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
442 virtual void OnPaint() |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
443 { |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
444 this->DrawWidgets(); |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
445 } |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
446 |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
447 virtual void DrawWidget(const Rect &r, int widget) const |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
448 { |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
449 if (widget != AW_SCROLLING_TEXT) return; |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
450 |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
451 int y = this->text_position; |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
452 |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
453 /* Show all scrolling _credits */ |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
454 for (uint i = 0; i < lengthof(_credits); i++) { |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
455 if (y >= r.top + 7 && y < r.bottom - this->line_height) { |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
456 DrawString(r.left, r.right, y, _credits[i], TC_BLACK, SA_LEFT | SA_FORCE); |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
457 } |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
458 y += this->line_height; |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
459 } |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
460 } |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
461 |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
462 virtual void OnTick() |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
463 { |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
464 if (--this->counter == 0) { |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
465 this->counter = 5; |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
466 this->text_position--; |
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
467 /* If the last text has scrolled start a new from the start */ |
13670
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
468 if (this->text_position < (int)(this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y - lengthof(_credits) * this->line_height)) { |
2e7ff39e2ec6
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
rubidium <rubidium@openttd.org>
parents:
13647
diff
changeset
|
469 this->text_position = this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->current_y; |
12820
a8612d0074e8
(svn r17310) -Codechange: about window uses nested widget tree
yexo <yexo@openttd.org>
parents:
12819
diff
changeset
|
470 } |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
471 this->SetDirty(); |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
472 } |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
473 } |
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
474 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
475 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
476 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
|
477 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
478 DeleteWindowById(WC_GAME_OPTIONS, 0); |
9227
35dbb597e9fd
(svn r13093) -Codechange: make a class of AboutWindow.
glx <glx@openttd.org>
parents:
9226
diff
changeset
|
479 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
|
480 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
481 |
11793
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
482 /** Widgets of the error message windows */ |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
483 enum ErrorMessageWidgets { |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
484 EMW_CAPTION, |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
485 EMW_FACE, |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
486 EMW_MESSAGE, |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
487 }; |
e11bc207c6e2
(svn r16183) -Fix [FS#2872]: wrong string alignment for error messages with face
rubidium <rubidium@openttd.org>
parents:
11792
diff
changeset
|
488 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
489 static const NWidgetPart _nested_errmsg_widgets[] = { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
490 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
491 NWidget(WWT_CLOSEBOX, COLOUR_RED), |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
492 NWidget(WWT_CAPTION, COLOUR_RED, EMW_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL), |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
493 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
494 NWidget(WWT_PANEL, COLOUR_RED), |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
495 NWidget(WWT_EMPTY, COLOUR_RED, EMW_MESSAGE), SetPadding(0, 2, 0, 2), SetMinimalSize(236, 32), |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
496 EndContainer(), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
497 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
498 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
499 static const WindowDesc _errmsg_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13797
diff
changeset
|
500 WDP_MANUAL, 0, 0, |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
501 WC_ERRMSG, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
502 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
503 _nested_errmsg_widgets, lengthof(_nested_errmsg_widgets) |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
504 ); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
505 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
506 static const NWidgetPart _nested_errmsg_face_widgets[] = { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
507 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
508 NWidget(WWT_CLOSEBOX, COLOUR_RED), |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
509 NWidget(WWT_CAPTION, COLOUR_RED, EMW_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_NULL), |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
510 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
511 NWidget(WWT_PANEL, COLOUR_RED), |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
512 NWidget(NWID_HORIZONTAL), SetPIP(2, 1, 2), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
513 NWidget(WWT_EMPTY, COLOUR_RED, EMW_FACE), SetMinimalSize(91, 120), SetFill(0, 1), SetPadding(2, 0, 1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
514 NWidget(WWT_EMPTY, COLOUR_RED, EMW_MESSAGE), SetFill(0, 1), SetMinimalSize(238, 123), |
11837
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
515 EndContainer(), |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
516 EndContainer(), |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
517 }; |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
518 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
519 static const WindowDesc _errmsg_face_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13797
diff
changeset
|
520 WDP_MANUAL, 0, 0, |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
521 WC_ERRMSG, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
522 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
523 _nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets) |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
524 ); |
11837
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
525 |
13412
c4c8d177431a
(svn r17921) -Documentation: Add doxygen comments in the ErrmsgWindow struct.
alberth <alberth@openttd.org>
parents:
13410
diff
changeset
|
526 /** Window class for displaying an error message window. */ |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
527 struct ErrmsgWindow : public Window { |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
528 private: |
13412
c4c8d177431a
(svn r17921) -Documentation: Add doxygen comments in the ErrmsgWindow struct.
alberth <alberth@openttd.org>
parents:
13410
diff
changeset
|
529 uint duration; ///< Length of display of the message. 0 means forever, |
c4c8d177431a
(svn r17921) -Documentation: Add doxygen comments in the ErrmsgWindow struct.
alberth <alberth@openttd.org>
parents:
13410
diff
changeset
|
530 uint64 decode_params[20]; ///< Parameters of the message strings. |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
531 StringID summary_msg; ///< General error message showed in first line. Must be valid. |
13418
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
532 StringID detailed_msg; ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID. |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
533 uint height_summary; ///< Height of the #summary_msg string in pixels in the #EMW_MESSAGE widget. |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
534 uint height_detailed; ///< Height of the #detailed_msg string in pixels in the #EMW_MESSAGE widget. |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
535 Point position; ///< Position of the error message window. |
9682
ed50c006a790
(svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents:
9659
diff
changeset
|
536 |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
537 public: |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
538 ErrmsgWindow(Point pt, const WindowDesc *desc, StringID summary_msg, StringID detailed_msg, bool no_timeout) : Window() |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
539 { |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
540 this->position = pt; |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
541 this->duration = no_timeout ? 0 : _settings_client.gui.errmsg_duration; |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
542 CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params)); |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
543 this->summary_msg = summary_msg; |
13418
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
544 this->detailed_msg = detailed_msg; |
9682
ed50c006a790
(svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents:
9659
diff
changeset
|
545 |
13418
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
546 assert(summary_msg != INVALID_STRING_ID); |
9682
ed50c006a790
(svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents:
9659
diff
changeset
|
547 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
548 this->InitNested(desc); |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
549 } |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
550 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
551 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
552 { |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
553 if (widget != EMW_MESSAGE) return; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
554 |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
555 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
|
556 /* 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
|
557 * 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
|
558 */ |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
559 SwitchToErrorRefStack(); |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
560 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
|
561 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
562 int text_width = max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT); |
13426
52ba7aa7628d
(svn r17935) -Fix (r17933): Compensate for being inside a class.
alberth <alberth@openttd.org>
parents:
13424
diff
changeset
|
563 this->height_summary = GetStringHeight(this->summary_msg, text_width); |
52ba7aa7628d
(svn r17935) -Fix (r17933): Compensate for being inside a class.
alberth <alberth@openttd.org>
parents:
13424
diff
changeset
|
564 this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width); |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
565 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
566 SwitchToNormalRefStack(); // Switch back to the normal text ref. stack for NewGRF texts. |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
567 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
568 uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM; |
13426
52ba7aa7628d
(svn r17935) -Fix (r17933): Compensate for being inside a class.
alberth <alberth@openttd.org>
parents:
13424
diff
changeset
|
569 if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE; |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
570 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
571 size->height = max(size->height, panel_height); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
572 } |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
573 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
574 virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
575 { |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
576 /* Position (0, 0) given, center the window. */ |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
577 if (this->position.x == 0 && this->position.y == 0) { |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
578 Point pt = {(_screen.width - sm_width) >> 1, (_screen.height - sm_height) >> 1}; |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
579 return pt; |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
580 } |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
581 |
13478
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
582 /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
583 * Add a fixed distance 20 to make it less cluttered. |
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
584 */ |
13478
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
585 int scr_top = GetMainViewTop() + 20; |
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
586 int scr_bot = GetMainViewBottom() - 20; |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
587 |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
588 Point pt = RemapCoords2(this->position.x, this->position.y); |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
589 const ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
13426
52ba7aa7628d
(svn r17935) -Fix (r17933): Compensate for being inside a class.
alberth <alberth@openttd.org>
parents:
13424
diff
changeset
|
590 if (this->detailed_msg != STR_ERROR_OWNED_BY || GetDParamX(this->decode_params, 2) >= MAX_COMPANIES) { |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
591 /* move x pos to opposite corner */ |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
592 pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left; |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
593 pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen. |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
594 |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
595 /* move y pos to opposite corner */ |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
596 pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
597 pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top; |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
598 } else { |
13426
52ba7aa7628d
(svn r17935) -Fix (r17933): Compensate for being inside a class.
alberth <alberth@openttd.org>
parents:
13424
diff
changeset
|
599 pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0, _screen.width - sm_width); |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
600 pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top, scr_bot - sm_height); |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
601 } |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
602 return pt; |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
603 } |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
604 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
605 virtual void OnPaint() |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
606 { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
607 this->DrawWidgets(); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
608 } |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
609 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
610 virtual void SetStringParameters(int widget) const |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
611 { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
612 if (widget == EMW_CAPTION) CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
613 } |
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
|
614 |
13422
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
615 virtual void DrawWidget(const Rect &r, int widget) const |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
616 { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
617 switch (widget) { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
618 case EMW_FACE: { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
619 const Company *c = Company::Get((CompanyID)GetDParamX(this->decode_params, 2)); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
620 DrawCompanyManagerFace(c->face, c->colour, r.left, r.top); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
621 break; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
622 } |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
623 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
624 case EMW_MESSAGE: |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
625 CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
626 SwitchToErrorRefStack(); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
627 RewindTextRefStack(); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
628 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
629 if (this->detailed_msg == INVALID_STRING_ID) { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
630 DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
631 this->summary_msg, TC_FROMSTRING, SA_CENTER); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
632 } else { |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
633 int extra = (r.bottom - r.top + 1 - this->height_summary - this->height_detailed - WD_PAR_VSEP_WIDE) / 2; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
634 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
635 int top = r.top + WD_FRAMERECT_TOP; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
636 int bottom = top + this->height_summary + extra; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
637 DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->summary_msg, TC_FROMSTRING, SA_CENTER); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
638 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
639 bottom = r.bottom - WD_FRAMERECT_BOTTOM; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
640 top = bottom - this->height_detailed - extra; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
641 DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, top, bottom, this->detailed_msg, TC_FROMSTRING, SA_CENTER); |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
642 } |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
643 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
644 SwitchToNormalRefStack(); // Switch back to the normal text ref. stack for NewGRF texts. |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
645 break; |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
646 |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
647 default: |
88d840d0eeb9
(svn r17931) -Codechange: Error message window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13419
diff
changeset
|
648 break; |
13415
65f20d71b375
(svn r17924) -Codechange: Replace y array with two area rectangles in the error message window.
alberth <alberth@openttd.org>
parents:
13412
diff
changeset
|
649 } |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
650 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
651 |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
652 virtual void OnMouseLoop() |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
653 { |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
654 /* Disallow closing the window too easily, if timeout is disabled */ |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
655 if (_right_button_down && this->duration != 0) delete this; |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
656 } |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
657 |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
658 virtual void OnHundredthTick() |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
659 { |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
660 /* Timeout enabled? */ |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
661 if (this->duration != 0) { |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
662 this->duration--; |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
663 if (this->duration == 0) delete this; |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
664 } |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
665 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
666 |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
667 ~ErrmsgWindow() |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
668 { |
10816
35b3e8e25590
(svn r15151) -Fix: tile 0 can now be highlighted as error tile
Yexo <Yexo@openttd.org>
parents:
10771
diff
changeset
|
669 SetRedErrorSquare(INVALID_TILE); |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
670 extern StringID _switch_mode_errorstr; |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
671 _switch_mode_errorstr = INVALID_STRING_ID; |
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
672 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 |
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
|
674 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
|
675 { |
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
|
676 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
|
677 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
|
678 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
|
679 } |
9265
746b863fafe6
(svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx <glx@openttd.org>
parents:
9228
diff
changeset
|
680 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
681 |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
682 /** |
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
683 * Display an error message in a window. |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
684 * @param summary_msg General error message showed in first line. Must be valid. |
13418
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
685 * @param detailed_msg Detailed error message showed in second line. Can be INVALID_STRING_ID. |
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
686 * @param x World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. |
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
687 * @param y World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. |
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
688 * @param no_timeout Set to true, if the message is that important that it should not close automatically after some time. |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
689 */ |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
690 void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, int x, int y, bool no_timeout) |
5584
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 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
|
693 |
12008
066420f32d18
(svn r16414) -Change: Make it harder to ignore/close important error messages. Esp. do not close them automatically after some time.
frosch <frosch@openttd.org>
parents:
11972
diff
changeset
|
694 if (_settings_client.gui.errmsg_duration == 0 && !no_timeout) 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
|
695 |
13418
a05425167e89
(svn r17927) -Codechange: Rename error message string variables.
alberth <alberth@openttd.org>
parents:
13415
diff
changeset
|
696 if (summary_msg == STR_NULL) summary_msg = 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
|
697 |
13424
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
698 Point pt = {x, y}; |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
699 const WindowDesc *desc = (detailed_msg != STR_ERROR_OWNED_BY || GetDParam(2) >= MAX_COMPANIES) ? &_errmsg_desc : &_errmsg_face_desc; |
3dd4ac4f5364
(svn r17933) -Codechange: Move position calculation of error message window into the class.
alberth <alberth@openttd.org>
parents:
13423
diff
changeset
|
700 new ErrmsgWindow(pt, desc, summary_msg, detailed_msg, no_timeout); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
701 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
702 |
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
|
703 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
|
704 { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
705 StringID msg = STR_MESSAGE_ESTIMATED_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
|
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 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
|
708 cost = -cost; |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
709 msg = STR_MESSAGE_ESTIMATED_INCOME; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
710 } |
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
|
711 SetDParam(0, cost); |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
712 ShowErrorMessage(msg, INVALID_STRING_ID, x, 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
|
713 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 |
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
|
715 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
|
716 { |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10582
diff
changeset
|
717 Point pt = RemapCoords(x, y, z); |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
718 StringID msg = STR_INCOME_FLOAT_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
|
719 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 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
|
721 cost = -cost; |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
722 msg = STR_INCOME_FLOAT_INCOME; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 } |
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
|
724 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
|
725 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
|
726 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 |
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
|
728 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
|
729 { |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10582
diff
changeset
|
730 Point pt = RemapCoords(x, y, z); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
731 |
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
|
732 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
|
733 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
|
734 } |
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
|
735 |
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
|
736 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
|
737 { |
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
|
738 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
|
739 |
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
|
740 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
|
741 |
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
|
742 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
|
743 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
|
744 } |
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
|
745 |
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
|
746 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
|
747 { |
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
|
748 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
|
749 |
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
|
750 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
|
751 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
|
752 } |
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
|
753 |
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
|
754 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
|
755 { |
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
|
756 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
|
757 |
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
|
758 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
|
759 *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
|
760 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
761 |
11837
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
762 static const NWidgetPart _nested_tooltips_widgets[] = { |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
763 NWidget(WWT_PANEL, COLOUR_GREY, 0), SetMinimalSize(200, 32), EndContainer(), |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
764 }; |
f32d9dd80187
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
alberth <alberth@openttd.org>
parents:
11793
diff
changeset
|
765 |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
766 static const WindowDesc _tool_tips_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13792
diff
changeset
|
767 WDP_MANUAL, 0, 0, // Coordinates and sizes are not used, |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
768 WC_TOOLTIPS, WC_NONE, |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
769 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
770 _nested_tooltips_widgets, lengthof(_nested_tooltips_widgets) |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
771 ); |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
772 |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
773 /** Window for displaying a tooltip. */ |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
774 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
|
775 { |
13404
4f5e54adb480
(svn r17913) -Documentation: Add doxygen comments to the tooltip window class.
alberth <alberth@openttd.org>
parents:
13344
diff
changeset
|
776 StringID string_id; ///< String to display as tooltip. |
4f5e54adb480
(svn r17913) -Documentation: Add doxygen comments to the tooltip window class.
alberth <alberth@openttd.org>
parents:
13344
diff
changeset
|
777 byte paramcount; ///< Number of string parameters in #string_id. |
4f5e54adb480
(svn r17913) -Documentation: Add doxygen comments to the tooltip window class.
alberth <alberth@openttd.org>
parents:
13344
diff
changeset
|
778 uint64 params[5]; ///< The string parameters. |
4f5e54adb480
(svn r17913) -Documentation: Add doxygen comments to the tooltip window class.
alberth <alberth@openttd.org>
parents:
13344
diff
changeset
|
779 bool use_left_mouse_button; ///< Wait for left mouse button to close window (else, wait for right button). |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
780 |
13409
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
781 TooltipsWindow(StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button) : Window() |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
782 { |
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
783 this->string_id = str; |
12927
950767ea4ee5
(svn r17420) -Codechange: replace assert() by assert_compile() where possible
smatz <smatz@openttd.org>
parents:
12878
diff
changeset
|
784 assert_compile(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
|
785 assert(paramcount <= lengthof(this->params)); |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
786 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
|
787 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
|
788 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
|
789 |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
790 this->InitNested(&_tool_tips_desc); |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
791 |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
792 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
|
793 } |
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 |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
795 virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
796 { |
13478
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
797 /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
798 * Add a fixed distance 2 so the tooltip floats free from both bars. |
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
799 */ |
13478
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
800 int scr_top = GetMainViewTop() + 2; |
d0e25c1f205e
(svn r17997) -Codechange: Introduce functions for querying top and bottom of the main view.
alberth <alberth@openttd.org>
parents:
13466
diff
changeset
|
801 int scr_bot = GetMainViewBottom() - 2; |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
802 |
13408
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
803 Point pt; |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
804 |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
805 /* Correctly position the tooltip position, watch out for window and cursor size |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
806 * Clamp value to below main toolbar and above statusbar. If tooltip would |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
807 * go below window, flip it so it is shown above the cursor */ |
13431
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
808 pt.y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, scr_top, scr_bot); |
80d05eb53cfa
(svn r17940) -Codechange: Use real y position of the main toolbar and status bar instead of hardcoded sizes for tooltip and for error message windows.
alberth <alberth@openttd.org>
parents:
13426
diff
changeset
|
809 if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.offs.y - 5, scr_bot) - sm_height; |
13408
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
810 pt.x = Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width); |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
811 |
763cbbda43f0
(svn r17917) -Codechange: Move tooltip initial position calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13407
diff
changeset
|
812 return pt; |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
813 } |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
814 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
815 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
816 { |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
817 /* There is only one widget. */ |
13409
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
818 for (uint i = 0; i != this->paramcount; i++) SetDParam(i, this->params[i]); |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
819 |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
820 size->width = min(GetStringBoundingBox(this->string_id).width, 194); |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
821 size->height = GetStringHeight(this->string_id, size->width); |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
822 |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
823 /* Increase slightly to have some space around the box. */ |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
824 size->width += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; |
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
825 size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
826 } |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
827 |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
828 virtual void DrawWidget(const Rect &r, int widget) const |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
829 { |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
830 /* There is only one widget. */ |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
831 GfxFillRect(r.left, r.top, r.right, r.bottom, 0); |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
832 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, 0x44); |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
833 |
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
834 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
|
835 SetDParam(arg, this->params[arg]); |
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
836 } |
13407
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
837 DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, this->string_id, TC_FROMSTRING, SA_CENTER); |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
838 } |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
839 |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
840 |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
841 virtual void OnPaint() |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
842 { |
dab0b75044af
(svn r17916) -Codechange: Make tooltips window use pure nested widgets.
alberth <alberth@openttd.org>
parents:
13405
diff
changeset
|
843 this->DrawWidgets(); |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
844 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
846 virtual void OnMouseLoop() |
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
847 { |
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
848 /* 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
|
849 * 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
|
850 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
|
851 } |
9186
c5c545191a71
(svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium <rubidium@openttd.org>
parents:
9179
diff
changeset
|
852 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
853 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
854 /** Shows a tooltip |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
855 * @param str String to be displayed |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
856 * @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
|
857 * @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
|
858 * @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
|
859 */ |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9752
diff
changeset
|
860 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
|
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 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
|
863 |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9752
diff
changeset
|
864 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
|
865 |
13409
955895a91fe4
(svn r17918) -Codechange: Move tooltip size calculation into the tooltip window class.
alberth <alberth@openttd.org>
parents:
13408
diff
changeset
|
866 new TooltipsWindow(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
|
867 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 |
13996
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
869 /** |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
870 * Draw a (multi)line of cargos seperated by commas, and prefixed with a string. |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
871 * @param cargo_mask Mask of cargos to include in the list. |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
872 * @param r Rectangle to draw the cargos in. |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
873 * @param prefix String to use as prefix for the list of cargos. |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
874 * @return Bottom position of the last line used for drawing the cargos. |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
875 */ |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
876 int DrawCargoListText(uint32 cargo_mask, const Rect &r, StringID prefix) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 bool first = true; |
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
|
879 char string[512]; |
13996
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
880 char *b = InlineString(string, prefix); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 |
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
|
882 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
|
883 if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
13996
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
884 if (HasBit(cargo_mask, i)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 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
|
886 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
|
887 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 /* 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
|
889 *b++ = ','; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 *b++ = ' '; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
891 } |
12415
6a77d1df56e2
(svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents:
12365
diff
changeset
|
892 b = InlineString(b, CargoSpec::Get(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
|
893 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
894 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
895 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 /* If first is still true then no cargo is accepted */ |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
897 if (first) b = InlineString(b, STR_JUST_NOTHING); |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 *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
|
900 |
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
|
901 /* 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
|
902 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
|
903 |
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
|
904 SetDParamStr(0, string); |
13996
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
905 return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_JUST_RAW_STRING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
906 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
907 |
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
|
908 /** |
838e1d6a0321
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium <rubidium@openttd.org>
parents:
8831
diff
changeset
|
909 * Calculates and draws the accepted or supplied cargo around the selected tile(s) |
12365
a56923c27ba6
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
yexo <yexo@openttd.org>
parents:
12263
diff
changeset
|
910 * @param left x position where the string is to be drawn |
a56923c27ba6
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
yexo <yexo@openttd.org>
parents:
12263
diff
changeset
|
911 * @param right the right most position to draw on |
a56923c27ba6
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
yexo <yexo@openttd.org>
parents:
12263
diff
changeset
|
912 * @param top y position where the string is to be drawn |
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
|
913 * @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
|
914 * @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
|
915 * @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
|
916 * @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
|
917 */ |
12365
a56923c27ba6
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
yexo <yexo@openttd.org>
parents:
12263
diff
changeset
|
918 int DrawStationCoverageAreaText(int left, int right, int top, 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
|
919 { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
920 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
921 if (tile < MapSize()) { |
12263
2af84c928595
(svn r16678) -Codechange: Turn CargoArray into a class, so one does not have to deal with sizeof() wrt. typedef-ed arrays.
frosch <frosch@openttd.org>
parents:
12262
diff
changeset
|
922 CargoArray cargos; |
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
|
923 if (supplies) { |
12263
2af84c928595
(svn r16678) -Codechange: Turn CargoArray into a class, so one does not have to deal with sizeof() wrt. typedef-ed arrays.
frosch <frosch@openttd.org>
parents:
12262
diff
changeset
|
924 cargos = GetProductionAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
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
|
925 } else { |
12263
2af84c928595
(svn r16678) -Codechange: Turn CargoArray into a class, so one does not have to deal with sizeof() wrt. typedef-ed arrays.
frosch <frosch@openttd.org>
parents:
12262
diff
changeset
|
926 cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
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
|
927 } |
13996
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
928 |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
929 /* Convert cargo counts to a set of cargo bits, and draw the result. */ |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
930 uint32 cargo_mask = 0; |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
931 for (CargoID i = 0; i < NUM_CARGO; i++) { |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
932 switch (sct) { |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
933 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
934 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
935 case SCT_ALL: break; |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
936 default: NOT_REACHED(); |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
937 } |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
938 if (cargos[i] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, i); |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
939 } |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
940 Rect r = {left, top, right, INT32_MAX}; |
3f141ce0d4ec
(svn r18538) -Codechange: Split DrawStationCoverageText into a calculation part and a drawing part.
alberth <alberth@openttd.org>
parents:
13798
diff
changeset
|
941 return DrawCargoListText(cargo_mask, r, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_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
|
942 } |
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
|
943 |
12365
a56923c27ba6
(svn r16789) -Codechange: unify the drawing of the Accepts/Supplies cargo lists in the station build windows.
yexo <yexo@openttd.org>
parents:
12263
diff
changeset
|
944 return 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
|
945 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
946 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
947 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
|
948 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 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
|
950 _thd.dirty &= ~1; |
13027
c02d5e082def
(svn r17525) -Cleanup: Remove SetWindowDirty(), it is completely covered by other functions already.
frosch <frosch@openttd.org>
parents:
13008
diff
changeset
|
951 w->SetDirty(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
952 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
953 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
954 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
955 /* 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
|
956 * 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
|
957 * 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
|
958 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
|
959 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
960 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
|
961 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
|
962 |
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
|
963 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
|
964 |
9390
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
965 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
|
966 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
|
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 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
|
969 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
|
970 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
|
971 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
|
972 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
974 /* 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
|
975 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
|
976 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
|
977 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
978 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
979 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
980 * 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
|
981 * 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
|
982 * @param tb Textbuf type to be changed |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
983 * @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
|
984 * @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
|
985 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
986 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
|
987 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
988 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
|
989 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
|
990 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
|
991 } 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
|
992 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
|
993 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
|
994 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
995 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
996 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
|
997 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
998 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
999 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1000 * Delete every character in the textbuffer |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
1001 * @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
|
1002 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1003 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
|
1004 { |
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
|
1005 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
|
1006 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
|
1007 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
|
1008 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1009 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1010 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1011 * 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
|
1012 * 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
|
1013 * length of the string |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
1014 * @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
|
1015 * @param key Character to be inserted |
7372
694c7b595661
(svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138 <peter1138@openttd.org>
parents:
7346
diff
changeset
|
1016 * @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
|
1017 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1018 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
|
1019 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 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
|
1029 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
|
1030 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
|
1031 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1032 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 /** |
13201
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1036 * Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1037 * and append this up to the maximum length (either absolute or screenlength). If maxlength |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1038 * is zero, we don't care about the screenlength but only about the physical length of the string |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1039 * @param tb Textbuf type to be changed |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1040 * @return true on successful change of Textbuf, or false otherwise |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1041 */ |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1042 bool InsertTextBufferClipboard(Textbuf *tb) |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1043 { |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1044 char utf8_buf[512]; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1045 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1046 if (!GetClipboardContents(utf8_buf, lengthof(utf8_buf))) return false; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1047 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1048 uint16 width = 0, length = 0; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1049 WChar c; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1050 for (const char *ptr = utf8_buf; (c = Utf8Consume(&ptr)) != '\0';) { |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1051 if (!IsPrintable(c)) break; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1052 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1053 byte len = Utf8CharLen(c); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1054 if (tb->size + length + len > tb->maxsize) break; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1055 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1056 byte charwidth = GetCharacterWidth(FS_NORMAL, c); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1057 if (tb->maxwidth != 0 && width + tb->width + charwidth > tb->maxwidth) break; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1058 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1059 width += charwidth; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1060 length += len; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1061 } |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1062 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1063 if (length == 0) return false; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1064 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1065 memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->size - tb->caretpos); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1066 memcpy(tb->buf + tb->caretpos, utf8_buf, length); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1067 tb->width += width; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1068 tb->caretxoffs += width; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1069 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1070 tb->size += length; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1071 tb->caretpos += length; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1072 assert(tb->size <= tb->maxsize); |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1073 tb->buf[tb->size - 1] = '\0'; // terminating zero |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1074 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1075 return true; |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1076 } |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1077 |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1078 /** |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1079 * 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
|
1080 * 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
|
1081 * @param tb Textbuf type where navigation occurs |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
1082 * @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
|
1083 * @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
|
1084 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1085 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
|
1086 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1087 switch (navmode) { |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1088 case WKC_LEFT: |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1089 if (tb->caretpos != 0) { |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1090 WChar c; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1091 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
|
1092 Utf8Decode(&c, s); |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1093 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
|
1094 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
|
1095 |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1096 return true; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1097 } |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1098 break; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1099 |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1100 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
|
1101 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
|
1102 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
|
1103 |
9390
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
1104 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
|
1105 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
|
1106 |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1107 return true; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1108 } |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1109 break; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1110 |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1111 case WKC_HOME: |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1112 tb->caretpos = 0; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1113 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
|
1114 return true; |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1115 |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1116 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
|
1117 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
|
1118 tb->caretxoffs = tb->width; |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1119 return true; |
8819
98ec34b70edd
(svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents:
8809
diff
changeset
|
1120 |
98ec34b70edd
(svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents:
8809
diff
changeset
|
1121 default: |
98ec34b70edd
(svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents:
8809
diff
changeset
|
1122 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
|
1123 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 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
|
1126 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1129 * 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
|
1130 * 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
|
1131 * @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
|
1132 * @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
|
1133 * @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
|
1134 * @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
|
1135 * 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
|
1136 * 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
|
1137 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
|
1138 { |
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
|
1139 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
|
1140 |
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
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1148 /** |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
1149 * 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
|
1150 * 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
|
1151 * 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
|
1152 * @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
|
1153 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1154 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
|
1155 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1156 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
|
1157 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 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
|
1159 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
|
1160 |
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
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1166 |
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
|
1167 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
|
1168 |
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
|
1169 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
|
1170 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
|
1171 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1172 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1173 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
|
1174 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1175 /* 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
|
1176 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
|
1177 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 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
|
1179 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
|
1180 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
|
1181 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1182 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
|
1183 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1184 |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1185 bool QueryString::HasEditBoxFocus(const Window *w, int wid) const |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1186 { |
12103
eecff8281292
(svn r16516) -Codechange: Added click and drag handling for nested widgets.
alberth <alberth@openttd.org>
parents:
12080
diff
changeset
|
1187 if (w->IsWidgetGloballyFocused(wid)) return true; |
eecff8281292
(svn r16516) -Codechange: Added click and drag handling for nested widgets.
alberth <alberth@openttd.org>
parents:
12080
diff
changeset
|
1188 if (w->window_class != WC_OSK || _focused_window != w->parent) return false; |
13570
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1189 return w->parent->nested_focus != NULL && w->parent->nested_focus->type == WWT_EDITBOX; |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1190 } |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1191 |
10295
7ebf43f7c36b
(svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents:
10276
diff
changeset
|
1192 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
|
1193 { |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1194 if (!QueryString::HasEditBoxFocus(w, wid)) return HEBR_NOT_FOCUSED; |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1195 |
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
|
1196 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
|
1197 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1198 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
|
1199 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
|
1200 |
10295
7ebf43f7c36b
(svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents:
10276
diff
changeset
|
1201 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
|
1202 |
13201
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1203 #ifdef WITH_COCOA |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1204 case (WKC_META | 'V'): |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1205 #endif |
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
|
1206 case (WKC_CTRL | 'V'): |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1207 if (InsertTextBufferClipboard(&this->text)) w->SetWidgetDirty(wid); |
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
|
1208 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
|
1209 |
13201
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1210 #ifdef WITH_COCOA |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1211 case (WKC_META | 'U'): |
4ebcd304709f
(svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents:
13186
diff
changeset
|
1212 #endif |
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
|
1213 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
|
1214 DeleteTextBufferAll(&this->text); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1215 w->SetWidgetDirty(wid); |
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
|
1216 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
|
1217 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1218 case WKC_BACKSPACE: case WKC_DELETE: |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1219 if (DeleteTextBufferChar(&this->text, keycode)) w->SetWidgetDirty(wid); |
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
|
1220 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
|
1221 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1222 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1223 if (MoveTextBufferPos(&this->text, keycode)) w->SetWidgetDirty(wid); |
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
|
1224 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
|
1225 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1226 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
|
1227 if (IsValidChar(key, this->afilter)) { |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1228 if (InsertTextBufferChar(&this->text, key)) w->SetWidgetDirty(wid); |
11319
340c5c4473f7
(svn r15669) -Change: Key presses that are not handles by an input box are no longer marked as handled but given to other OnKeyPress handlers. This makes the global shortcuts like F1 work again when an input box is open.
yexo <yexo@openttd.org>
parents:
11256
diff
changeset
|
1229 } else { |
340c5c4473f7
(svn r15669) -Change: Key presses that are not handles by an input box are no longer marked as handled but given to other OnKeyPress handlers. This makes the global shortcuts like F1 work again when an input box is open.
yexo <yexo@openttd.org>
parents:
11256
diff
changeset
|
1230 state = 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
|
1231 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1232 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1233 |
10295
7ebf43f7c36b
(svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents:
10276
diff
changeset
|
1234 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
|
1235 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1236 |
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
|
1237 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
|
1238 { |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1239 if (HasEditBoxFocus(w, wid) && HandleCaret(&this->text)) { |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1240 w->SetWidgetDirty(wid); |
10934
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1241 /* When we're not the OSK, notify 'our' OSK to redraw the widget, |
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1242 * so the caret changes appropriately. */ |
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1243 if (w->window_class != WC_OSK) { |
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1244 Window *w_osk = FindWindowById(WC_OSK, 0); |
13169
1f44cefc7825
(svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents:
13163
diff
changeset
|
1245 if (w_osk != NULL && w_osk->parent == w) w_osk->InvalidateData(); |
10934
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1246 } |
76f750feb4fc
(svn r15273) -Fix: OSK of the chat did not update the caret graphics
rubidium <rubidium@openttd.org>
parents:
10816
diff
changeset
|
1247 } |
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
|
1248 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1249 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1250 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
|
1251 { |
13570
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1252 const NWidgetBase *wi = w->GetWidget<NWidgetBase>(wid); |
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
|
1253 |
13570
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1254 assert((wi->type & WWT_MASK) == WWT_EDITBOX); |
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1255 int left = wi->pos_x; |
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1256 int right = wi->pos_x + wi->current_x - 1; |
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1257 int top = wi->pos_y; |
4a7574282ac8
(svn r18092) -Codechange: remove support for the unnested widgets
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
1258 int bottom = wi->pos_y + wi->current_y - 1; |
13008
3abc6651764b
(svn r17502) -Codechange [FS#3184]: Extend QueryStringBaseWindow to support windows with nested widgets (by Terkhen with a few tweaks).
alberth <alberth@openttd.org>
parents:
12946
diff
changeset
|
1259 |
3abc6651764b
(svn r17502) -Codechange [FS#3184]: Extend QueryStringBaseWindow to support windows with nested widgets (by Terkhen with a few tweaks).
alberth <alberth@openttd.org>
parents:
12946
diff
changeset
|
1260 GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, 215); |
8819
98ec34b70edd
(svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents:
8809
diff
changeset
|
1261 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1262 /* Limit the drawing of the string inside the widget boundaries */ |
13008
3abc6651764b
(svn r17502) -Codechange [FS#3184]: Extend QueryStringBaseWindow to support windows with nested widgets (by Terkhen with a few tweaks).
alberth <alberth@openttd.org>
parents:
12946
diff
changeset
|
1263 DrawPixelInfo dpi; |
13118
cf2b48d0ea33
(svn r17620) -Fix (r17502): edit box offsets were off. Now they're still off, but look (in my opinion) even better than before
rubidium <rubidium@openttd.org>
parents:
13096
diff
changeset
|
1264 if (!FillDrawPixelInfo(&dpi, left + WD_FRAMERECT_LEFT, top + WD_FRAMERECT_TOP, right - left - WD_FRAMERECT_RIGHT, bottom - top - WD_FRAMERECT_BOTTOM)) 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
|
1265 |
8819
98ec34b70edd
(svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz <smatz@openttd.org>
parents:
8809
diff
changeset
|
1266 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
|
1267 _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
|
1268 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1269 /* 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
|
1270 * 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
|
1271 const Textbuf *tb = &this->text; |
13008
3abc6651764b
(svn r17502) -Codechange [FS#3184]: Extend QueryStringBaseWindow to support windows with nested widgets (by Terkhen with a few tweaks).
alberth <alberth@openttd.org>
parents:
12946
diff
changeset
|
1272 int delta = min(0, (right - left) - tb->width - 10); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1273 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1274 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
|
1275 |
11436
caf4456fbbf3
(svn r15794) -Codechange: remove the DoDrawString part of the old text drawing API
rubidium <rubidium@openttd.org>
parents:
11429
diff
changeset
|
1276 DrawString(delta, tb->width, 0, tb->buf, TC_YELLOW); |
11482
684bb10eddfc
(svn r15843) -Codechange: with RTL the caret would always be drawn at the end of the textbox.
rubidium <rubidium@openttd.org>
parents:
11480
diff
changeset
|
1277 if (HasEditBoxFocus(w, wid) && tb->caret) { |
684bb10eddfc
(svn r15843) -Codechange: with RTL the caret would always be drawn at the end of the textbox.
rubidium <rubidium@openttd.org>
parents:
11480
diff
changeset
|
1278 int caret_width = GetStringBoundingBox("_").width; |
684bb10eddfc
(svn r15843) -Codechange: with RTL the caret would always be drawn at the end of the textbox.
rubidium <rubidium@openttd.org>
parents:
11480
diff
changeset
|
1279 DrawString(tb->caretxoffs + delta, tb->caretxoffs + delta + caret_width, 0, "_", TC_WHITE); |
684bb10eddfc
(svn r15843) -Codechange: with RTL the caret would always be drawn at the end of the textbox.
rubidium <rubidium@openttd.org>
parents:
11480
diff
changeset
|
1280 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1281 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 _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
|
1283 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 |
10563
2271e0ee2758
(svn r14820) -Codechange: use (the correct) enum-type instead of just int (Zuu)
rubidium <rubidium@openttd.org>
parents:
10547
diff
changeset
|
1285 HandleEditBoxResult 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
|
1286 { |
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
|
1287 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
|
1288 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1289 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1290 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
|
1291 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1292 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
|
1293 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1294 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1295 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
|
1296 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1297 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
|
1298 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1299 |
10547
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1300 void QueryStringBaseWindow::OnOpenOSKWindow(int wid) |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1301 { |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1302 ShowOnScreenKeyboard(this, wid, 0, 0); |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1303 } |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1304 |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1305 /** Widget of the string 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
|
1306 enum QueryStringWidgets { |
11652
f175ab1cccea
(svn r16032) -Codechange: Completing widget numbers of query windows.
alberth <alberth@openttd.org>
parents:
11644
diff
changeset
|
1307 QUERY_STR_WIDGET_CAPTION, |
f175ab1cccea
(svn r16032) -Codechange: Completing widget numbers of query windows.
alberth <alberth@openttd.org>
parents:
11644
diff
changeset
|
1308 QUERY_STR_WIDGET_TEXT, |
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
|
1309 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
|
1310 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
|
1311 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
|
1312 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1313 |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1314 /** Class for the string query window. */ |
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
|
1315 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
|
1316 { |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1317 QueryStringFlags flags; ///< Flags controlling behaviour of the window. |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1318 |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1319 QueryStringWindow(StringID str, StringID caption, uint maxsize, uint maxwidth, const WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1320 QueryStringBaseWindow(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
|
1321 { |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1322 GetString(this->edit_str_buf, str, &this->edit_str_buf[maxsize - 1]); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1323 this->edit_str_buf[maxsize - 1] = '\0'; |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1324 |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1325 if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->orig = strdup(this->edit_str_buf); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1326 |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1327 this->caption = caption; |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1328 this->afilter = afilter; |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1329 this->flags = flags; |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1330 InitializeTextBuffer(&this->text, this->edit_str_buf, maxsize, maxwidth); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1331 |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1332 this->InitNested(desc); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1333 |
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
|
1334 this->parent = parent; |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1335 |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1336 this->SetFocusedWidget(QUERY_STR_WIDGET_TEXT); |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1337 this->LowerWidget(QUERY_STR_WIDGET_TEXT); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1338 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1339 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
1340 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1341 { |
13457
91c47c384c4f
(svn r17966) -Fix (r17965): The Default button should be disabled in some cases rather than the Ok button.
alberth <alberth@openttd.org>
parents:
13456
diff
changeset
|
1342 if (widget == QUERY_STR_WIDGET_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1343 this->GetWidget<NWidgetCore>(widget)->SetFill(0, 1); |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1344 size->width = 0; |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1345 } |
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
|
1346 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1347 |
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
|
1348 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
|
1349 { |
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
|
1350 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
|
1351 |
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
|
1352 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
|
1353 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1354 |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1355 virtual void SetStringParameters(int widget) const |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1356 { |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1357 if (widget == QUERY_STR_WIDGET_CAPTION) SetDParam(0, this->caption); |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1358 } |
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1359 |
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
|
1360 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
|
1361 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1362 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
|
1363 /* 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
|
1364 * 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
|
1365 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
|
1366 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
|
1367 } 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
|
1368 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
|
1369 } |
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
|
1370 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
|
1371 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1372 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1373 |
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
|
1374 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
|
1375 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1376 switch (widget) { |
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
|
1377 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
|
1378 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
|
1379 /* 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
|
1380 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
|
1381 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
|
1382 /* 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
|
1383 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
|
1384 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
|
1385 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
|
1386 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1387 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1388 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1389 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
|
1390 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1391 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
|
1392 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 |
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
|
1394 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
|
1395 { |
11319
340c5c4473f7
(svn r15669) -Change: Key presses that are not handles by an input box are no longer marked as handled but given to other OnKeyPress handlers. This makes the global shortcuts like F1 work again when an input box is open.
yexo <yexo@openttd.org>
parents:
11256
diff
changeset
|
1396 EventState state = ES_NOT_HANDLED; |
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
|
1397 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
|
1398 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
|
1399 case HEBR_EDITING: { |
9399
617011acf06f
(svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents:
9394
diff
changeset
|
1400 Window *osk = FindWindowById(WC_OSK, 0); |
13169
1f44cefc7825
(svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents:
13163
diff
changeset
|
1401 if (osk != NULL && osk->parent == this) osk->InvalidateData(); |
9399
617011acf06f
(svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz <smatz@openttd.org>
parents:
9394
diff
changeset
|
1402 } break; |
10295
7ebf43f7c36b
(svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx <glx@openttd.org>
parents:
10276
diff
changeset
|
1403 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
|
1404 /* 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
|
1405 case HEBR_CANCEL: delete this; break; // close window, abandon changes |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1406 case HEBR_NOT_FOCUSED: break; |
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
|
1407 } |
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
|
1408 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
|
1409 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1410 |
10547
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1411 virtual void OnOpenOSKWindow(int wid) |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1412 { |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1413 ShowOnScreenKeyboard(this, wid, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK); |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1414 } |
0b7be1ee92c5
(svn r14804) -Codechange: unify opening the OSK (Zuu)
rubidium <rubidium@openttd.org>
parents:
10533
diff
changeset
|
1415 |
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
|
1416 ~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
|
1417 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1418 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
|
1419 Window *parent = this->parent; |
aeff7240b474
(svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz <smatz@openttd.org>
parents:
9390
diff
changeset
|
1420 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
|
1421 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
|
1422 } |
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
|
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 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1425 |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1426 static const NWidgetPart _nested_query_string_widgets[] = { |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1427 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1428 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
12821
9c5779a4ca5d
(svn r17311) -Change: rename STR_WHITE_STRINGN to STR_WHITE_STRING
yexo <yexo@openttd.org>
parents:
12820
diff
changeset
|
1429 NWidget(WWT_CAPTION, COLOUR_GREY, QUERY_STR_WIDGET_CAPTION), SetDataTip(STR_WHITE_STRING, STR_NULL), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1430 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
1431 NWidget(WWT_PANEL, COLOUR_GREY), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1432 NWidget(WWT_EDITBOX, COLOUR_GREY, QUERY_STR_WIDGET_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1433 EndContainer(), |
13458
c5fe26cd3457
(svn r17967) -Codechange: Specify that the buttons of the query string window should be equal in size.
alberth <alberth@openttd.org>
parents:
13457
diff
changeset
|
1434 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1435 NWidget(WWT_TEXTBTN, COLOUR_GREY, QUERY_STR_WIDGET_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1436 NWidget(WWT_TEXTBTN, COLOUR_GREY, QUERY_STR_WIDGET_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1437 NWidget(WWT_TEXTBTN, COLOUR_GREY, QUERY_STR_WIDGET_OK), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_OK, STR_NULL), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1438 EndContainer(), |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1439 }; |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1440 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
1441 static const WindowDesc _query_string_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13797
diff
changeset
|
1442 WDP_AUTO, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
1443 WC_QUERY_STRING, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
1444 0, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
1445 _nested_query_string_widgets, lengthof(_nested_query_string_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
1446 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1447 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1448 /** 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
|
1449 * @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
|
1450 * @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
|
1451 * @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
|
1452 * @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
|
1453 * @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
|
1454 * 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
|
1455 * @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
|
1456 * @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
|
1457 */ |
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
|
1458 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
|
1459 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1460 DeleteWindowById(WC_QUERY_STRING, 0); |
13456
93cf77b7a1ba
(svn r17965) -Codechange: query string window uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13436
diff
changeset
|
1461 new QueryStringWindow(str, caption, maxsize, maxwidth, &_query_string_desc, parent, afilter, 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
|
1462 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1463 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1464 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1465 enum QueryWidgets { |
11652
f175ab1cccea
(svn r16032) -Codechange: Completing widget numbers of query windows.
alberth <alberth@openttd.org>
parents:
11644
diff
changeset
|
1466 QUERY_WIDGET_CAPTION, |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1467 QUERY_WIDGET_TEXT, |
11652
f175ab1cccea
(svn r16032) -Codechange: Completing widget numbers of query windows.
alberth <alberth@openttd.org>
parents:
11644
diff
changeset
|
1468 QUERY_WIDGET_NO, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1469 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
|
1470 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1471 |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1472 /** |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1473 * 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
|
1474 */ |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1475 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
|
1476 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
|
1477 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
|
1478 StringID message; ///< message shown for query window |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1479 StringID caption; ///< title of 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
|
1480 |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1481 QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window() |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1482 { |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1483 /* Create a backup of the variadic arguments to strings because it will be |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1484 * overridden pretty often. We will copy these back for drawing */ |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1485 CopyOutDParam(this->params, 0, lengthof(this->params)); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1486 this->caption = caption; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1487 this->message = message; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1488 this->proc = callback; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1489 |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1490 this->InitNested(desc); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1491 |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1492 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
|
1493 this->parent = parent; |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1494 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
|
1495 this->top = parent->top + (parent->height / 2) - (this->height / 2); |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1496 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1497 |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1498 ~QueryWindow() |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1499 { |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1500 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
|
1501 } |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1502 |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1503 virtual void SetStringParameters(int widget) const |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1504 { |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1505 switch (widget) { |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1506 case QUERY_WIDGET_CAPTION: |
13174
cd71f89cd87f
(svn r17681) -Fix [FS#3248] (r17668): crash when the caption of the query window used parameters
rubidium <rubidium@openttd.org>
parents:
13169
diff
changeset
|
1507 CopyInDParam(1, this->params, lengthof(this->params)); |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1508 SetDParam(0, this->caption); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1509 break; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1510 |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1511 case QUERY_WIDGET_TEXT: |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1512 CopyInDParam(0, this->params, lengthof(this->params)); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1513 break; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1514 } |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1515 } |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1516 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
1517 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1518 { |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1519 if (widget != QUERY_WIDGET_TEXT) return; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1520 |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1521 Dimension d = GetStringMultiLineBoundingBox(this->message, *size); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1522 d.width += padding.width; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1523 d.height += padding.height; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1524 *size = d; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1525 } |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1526 |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1527 virtual void DrawWidget(const Rect &r, int widget) const |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1528 { |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1529 if (widget != QUERY_WIDGET_TEXT) return; |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1530 |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1531 DrawStringMultiLine(r.left, r.right, r.top, r.bottom, this->message, TC_FROMSTRING, SA_CENTER); |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1532 } |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1533 |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1534 virtual void OnPaint() |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1535 { |
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
|
1536 this->DrawWidgets(); |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1537 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1538 |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1539 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
|
1540 { |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1541 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
|
1542 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
|
1543 /* 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
|
1544 * 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
|
1545 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
|
1546 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
|
1547 /* 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
|
1548 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
|
1549 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
|
1550 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
|
1551 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
|
1552 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
|
1553 } |
9319
7c3d6f855380
(svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents:
9317
diff
changeset
|
1554 } break; |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1555 case QUERY_WIDGET_NO: |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1556 delete this; |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1557 break; |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1558 } |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1559 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1560 |
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
|
1561 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
|
1562 { |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1563 /* 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
|
1564 switch (keycode) { |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1565 case WKC_RETURN: |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1566 case WKC_NUM_ENTER: |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1567 if (this->proc != NULL) { |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1568 this->proc(this->parent, true); |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1569 this->proc = NULL; |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1570 } |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1571 /* Fallthrough */ |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1572 case WKC_ESC: |
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1573 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
|
1574 return ES_HANDLED; |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1575 } |
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
|
1576 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
|
1577 } |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1578 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1579 |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1580 static const NWidgetPart _nested_query_widgets[] = { |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1581 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1582 NWidget(WWT_CLOSEBOX, COLOUR_RED), |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1583 NWidget(WWT_CAPTION, COLOUR_RED, QUERY_WIDGET_CAPTION), SetDataTip(STR_JUST_STRING, STR_NULL), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1584 EndContainer(), |
13755
bf8a4ced15fe
(svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
1585 NWidget(WWT_PANEL, COLOUR_RED), SetPIP(8, 15, 8), |
13163
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1586 NWidget(WWT_TEXT, COLOUR_RED, QUERY_WIDGET_TEXT), SetMinimalSize(200, 12), |
3f7aeb884dcf
(svn r17668) -Codechange: Query window uses nested widgets
yexo <yexo@openttd.org>
parents:
13118
diff
changeset
|
1587 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(20, 29, 20), |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
1588 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, QUERY_WIDGET_NO), SetMinimalSize(71, 12), SetDataTip(STR_QUIT_NO, STR_NULL), |
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
1589 NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, QUERY_WIDGET_YES), SetMinimalSize(71, 12), SetDataTip(STR_QUIT_YES, STR_NULL), |
11653
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1590 EndContainer(), |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1591 EndContainer(), |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1592 }; |
50cfe1ce7e28
(svn r16033) -Codechange: Added nested widgets to about window, land-info window, and both query windows.
alberth <alberth@openttd.org>
parents:
11652
diff
changeset
|
1593 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
1594 static const WindowDesc _query_desc( |
13798
6f820ae12bb3
(svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents:
13797
diff
changeset
|
1595 WDP_CENTER, 0, 0, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
1596 WC_CONFIRM_POPUP_QUERY, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
1597 WDF_UNCLICK_BUTTONS | WDF_MODAL, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
1598 _nested_query_widgets, lengthof(_nested_query_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
1599 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1600 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1601 /** 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
|
1602 * 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
|
1603 * @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
|
1604 * @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
|
1605 * @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
|
1606 * 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
|
1607 * @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
|
1608 */ |
9319
7c3d6f855380
(svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz <smatz@openttd.org>
parents:
9317
diff
changeset
|
1609 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
|
1610 { |
9176
0f495f0a0c53
(svn r13039) -Codechange: make a class of the Query window.
rubidium <rubidium@openttd.org>
parents:
9170
diff
changeset
|
1611 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
|
1612 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1613 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1614 |
11862
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1615 enum SaveLoadWindowWidgets { |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1616 SLWW_WINDOWTITLE, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1617 SLWW_SORT_BYNAME, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1618 SLWW_SORT_BYDATE, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1619 SLWW_BACKGROUND, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1620 SLWW_FILE_BACKGROUND, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1621 SLWW_HOME_BUTTON, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1622 SLWW_DRIVES_DIRECTORIES_LIST, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1623 SLWW_SCROLLBAR, |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1624 SLWW_CONTENT_DOWNLOAD, ///< only available for play scenario/heightmap (content download) |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1625 SLWW_SAVE_OSK_TITLE, ///< only available for save operations |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1626 SLWW_DELETE_SELECTION, ///< same in here |
6e085df38529
(svn r16256) -Codechange: Moved load/save dialogue widget numbers outside the window struct.
alberth <alberth@openttd.org>
parents:
11852
diff
changeset
|
1627 SLWW_SAVE_GAME, ///< not to mention in here too |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1628 SLWW_CONTENT_DOWNLOAD_SEL, ///< Selection 'stack' to 'hide' the content download |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1629 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1630 |
11865
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1631 static const NWidgetPart _nested_load_dialog_widgets[] = { |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1632 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1633 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1634 NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1635 EndContainer(), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1636 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1637 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1638 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1639 EndContainer(), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1640 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1641 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1642 NWidget(NWID_HORIZONTAL), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1643 NWidget(NWID_VERTICAL), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1644 NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1645 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), EndContainer(), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1646 NWidget(NWID_SELECTION, INVALID_COLOUR, SLWW_CONTENT_DOWNLOAD_SEL), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1647 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_CONTENT_DOWNLOAD), SetResize(1, 0), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1648 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1649 EndContainer(), |
11865
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1650 EndContainer(), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1651 NWidget(NWID_VERTICAL), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1652 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1653 NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1654 NWidget(WWT_RESIZEBOX, COLOUR_GREY), |
11865
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1655 EndContainer(), |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1656 EndContainer(), |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1657 EndContainer(), |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1658 }; |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1659 |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1660 static const NWidgetPart _nested_save_dialog_widgets[] = { |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1661 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1662 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1663 NWidget(WWT_CAPTION, COLOUR_GREY, SLWW_WINDOWTITLE), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1664 EndContainer(), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1665 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1666 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1667 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1668 EndContainer(), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1669 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1670 NWidget(WWT_PANEL, COLOUR_GREY, SLWW_FILE_BACKGROUND), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1671 NWidget(NWID_HORIZONTAL), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1672 NWidget(WWT_INSET, COLOUR_GREY, SLWW_DRIVES_DIRECTORIES_LIST), SetPadding(2, 1, 0, 2), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1673 SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), EndContainer(), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1674 NWidget(NWID_VERTICAL), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1675 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, SLWW_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1676 NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLWW_SCROLLBAR), |
11865
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1677 EndContainer(), |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1678 EndContainer(), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1679 NWidget(WWT_EDITBOX, COLOUR_GREY, SLWW_SAVE_OSK_TITLE), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0), |
13410
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1680 SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1681 EndContainer(), |
3fb5398475cc
(svn r17919) -Codechange (r17849): Remove the outermost NWID_LAYERED and NWID_VERTICAL containers from the load and save nested widget parts, since they do nothing.
alberth <alberth@openttd.org>
parents:
13409
diff
changeset
|
1682 NWidget(NWID_HORIZONTAL), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1683 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_DELETE_SELECTION), SetDataTip(STR_SAVELOAD_DELETE_BUTTON, STR_SAVELOAD_DELETE_TOOLTIP), SetFill(1, 0), SetResize(1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13683
diff
changeset
|
1684 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_SAVE_GAME), SetDataTip(STR_SAVELOAD_SAVE_BUTTON, STR_SAVELOAD_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
1685 NWidget(WWT_RESIZEBOX, COLOUR_GREY), |
11865
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1686 EndContainer(), |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1687 }; |
a8d788b2bbd2
(svn r16259) -Codechange: Added nested widgets to the load and save dialogue windows.
alberth <alberth@openttd.org>
parents:
11864
diff
changeset
|
1688 |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
1689 /* Colours for fios types */ |
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
1690 const TextColour _fios_colours[] = { |
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
|
1691 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
|
1692 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
|
1693 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1694 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
1695 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
|
1696 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1697 _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
|
1698 FiosFreeSavegameList(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1699 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1700 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
|
1701 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
|
1702 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
|
1703 case SLD_SAVE_SCENARIO: |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1704 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
|
1705 case SLD_LOAD_HEIGHTMAP: |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1706 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
|
1707 |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1708 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
|
1709 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1710 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1711 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
1712 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
|
1713 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1714 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
|
1715 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
|
1716 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1717 /* 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
|
1718 * 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
|
1719 * 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
|
1720 */ |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
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 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1729 |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1730 uint s_amount = _fios_items.Length() - sort_start - sort_end; |
13030
12fa346326b0
(svn r17528) -Codechange: use QSortT instead of qsort for sorting FiosItems
rubidium <rubidium@openttd.org>
parents:
13027
diff
changeset
|
1731 QSortT(_fios_items.Get(sort_start), s_amount, CompareFiosItems); |
5584
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 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
1734 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
|
1735 |
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
|
1736 struct SaveLoadWindow : public QueryStringBaseWindow { |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1737 private: |
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
|
1738 FiosItem o_dir; |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1739 public: |
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
|
1740 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1741 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
|
1742 { |
10533
53a8506c2079
(svn r14790) -Codechange: unify generation of default savegame/screenshot names (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1743 GenerateDefaultSaveName(this->edit_str_buf, &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
|
1744 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1745 |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1746 SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64) |
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
|
1747 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1748 static const StringID saveload_captions[] = { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
1749 STR_SAVELOAD_LOAD_CAPTION, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
1750 STR_SAVELOAD_LOAD_SCENARIO, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
1751 STR_SAVELOAD_SAVE_CAPTION, |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
1752 STR_SAVELOAD_SAVE_SCENARIO, |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12619
diff
changeset
|
1753 STR_SAVELOAD_LOAD_HEIGHTMAP, |
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
|
1754 }; |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1755 assert((uint)mode < lengthof(saveload_captions)); |
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
|
1756 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1757 /* 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
|
1758 * 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
|
1759 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
|
1760 case SLD_SAVE_GAME: this->GenerateFileName(); break; |
11644
7980a47b17cb
(svn r16024) -Codechange: harden string copying on places where it's possible
rubidium <rubidium@openttd.org>
parents:
11544
diff
changeset
|
1761 case SLD_SAVE_SCENARIO: strecpy(this->edit_str_buf, "UNNAMED", &this->edit_str_buf[edit_str_size - 1]); break; |
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
|
1762 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
|
1763 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1764 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1765 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
|
1766 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
|
1767 |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1768 this->CreateNestedTree(desc); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1769 if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(SLWW_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(STACKED_SELECTION_ZERO_SIZE); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1770 this->GetWidget<NWidgetCore>(SLWW_WINDOWTITLE)->widget_data = saveload_captions[mode]; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1771 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1772 this->FinishInitNested(desc, 0); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1773 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1774 this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1775 |
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
|
1776 /* 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
|
1777 * 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
|
1778 if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { |
11852
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11837
diff
changeset
|
1779 DoCommandP(0, PM_PAUSED_SAVELOAD, 1, 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
|
1780 } |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1781 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); |
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
|
1782 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1783 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
|
1784 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1785 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
|
1786 |
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
|
1787 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
|
1788 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
|
1789 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
|
1790 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
|
1791 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
|
1792 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
|
1793 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1794 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
|
1795 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
|
1796 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
|
1797 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
|
1798 |
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
|
1799 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
|
1800 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
|
1801 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
|
1802 |
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
|
1803 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
|
1804 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
|
1805 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1806 |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1807 /* Focus the edit box by default in the save windows */ |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1808 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1809 this->SetFocusedWidget(SLWW_SAVE_OSK_TITLE); |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
1810 } |
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
|
1811 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1812 |
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
|
1813 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
|
1814 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1815 /* 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
|
1816 if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { |
11852
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11837
diff
changeset
|
1817 DoCommandP(0, PM_PAUSED_SAVELOAD, 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
|
1818 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1819 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
|
1820 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1821 |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1822 virtual void DrawWidget(const Rect &r, int widget) const |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1823 { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1824 switch (widget) { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1825 case SLWW_SORT_BYNAME: |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1826 case SLWW_SORT_BYDATE: |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1827 if (((_savegame_sort_order & SORT_BY_NAME) != 0) == (widget == SLWW_SORT_BYNAME)) { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1828 this->DrawSortButtonState(widget, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1829 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1830 break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1831 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1832 case SLWW_BACKGROUND: { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1833 static const char *path = NULL; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1834 static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1835 static uint64 tot = 0; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1836 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1837 if (_fios_path_changed) { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1838 str = FiosGetDescText(&path, &tot); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1839 _fios_path_changed = false; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1840 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1841 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1842 if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1843 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP, str); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1844 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, path, TC_BLACK); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1845 } break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1846 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1847 case SLWW_DRIVES_DIRECTORIES_LIST: { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1848 GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, 0xD7); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1849 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1850 uint y = r.top + WD_FRAMERECT_TOP; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1851 for (uint pos = this->vscroll.GetPosition(); pos < _fios_items.Length(); pos++) { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1852 const FiosItem *item = _fios_items.Get(pos); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1853 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1854 DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[item->type]); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1855 y += this->resize.step_height; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1856 if (y >= this->vscroll.GetCapacity() * this->resize.step_height + r.top + WD_FRAMERECT_TOP) break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1857 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1858 } break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1859 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1860 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1861 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
1862 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1863 { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1864 switch (widget) { |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1865 case SLWW_CONTENT_DOWNLOAD_SEL: |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1866 resize->width = 1; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1867 break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1868 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1869 case SLWW_BACKGROUND: |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1870 size->height = 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1871 break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1872 |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1873 case SLWW_DRIVES_DIRECTORIES_LIST: |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1874 resize->height = FONT_HEIGHT_NORMAL; |
13611
1e76fef2e9e2
(svn r18135) -Codechange: File list text overflowed its container.
peter1138 <peter1138@openttd.org>
parents:
13602
diff
changeset
|
1875 size->height = resize->height * 10 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1876 break; |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1877 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1878 } |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1879 |
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
|
1880 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
|
1881 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1882 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
|
1883 _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
|
1884 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
|
1885 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1886 |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1887 this->vscroll.SetCount(_fios_items.Length()); |
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1888 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
|
1889 |
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
|
1890 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1891 this->DrawEditBox(SLWW_SAVE_OSK_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
|
1892 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1893 } |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1894 |
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
|
1895 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
|
1896 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1897 switch (widget) { |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1898 case SLWW_SORT_BYNAME: // Sort save names by 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
|
1899 _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
|
1900 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
|
1901 _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
|
1902 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
|
1903 break; |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1904 |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1905 case SLWW_SORT_BYDATE: // Sort save names by date |
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
|
1906 _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
|
1907 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
|
1908 _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
|
1909 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
|
1910 break; |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1911 |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1912 case SLWW_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory |
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
|
1913 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
|
1914 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
|
1915 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
|
1916 break; |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1917 |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1918 case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox |
13340
d482f09e16bd
(svn r17849) -Codechange: make the saveload windows nested
rubidium <rubidium@openttd.org>
parents:
13277
diff
changeset
|
1919 int y = (pt.y - this->GetWidget<NWidgetBase>(SLWW_DRIVES_DIRECTORIES_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height; |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1920 |
12878
8ad447b80c42
(svn r17370) -Codechange: make the saveload and network GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents:
12867
diff
changeset
|
1921 if (y < 0 || (y += this->vscroll.GetPosition()) >= this->vscroll.GetCount()) return; |
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
|
1922 |
9441
e899ed594e7c
(svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents:
9413
diff
changeset
|
1923 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
|
1924 |
11256
f63c1d69ed92
(svn r15605) -Codechange: constify a function
rubidium <rubidium@openttd.org>
parents:
11230
diff
changeset
|
1925 const 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
|
1926 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
|
1927 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
|
1928 _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
|
1929 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1930 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
|
1931 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
|
1932 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
|
1933 |
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
|
1934 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
|
1935 } 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
|
1936 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
|
1937 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
|
1938 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
|
1939 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1940 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
|
1941 ShowHeightmapLoad(); |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1942 } 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
|
1943 /* 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
|
1944 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
|
1945 UpdateTextBufferSize(&this->text); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
1946 this->SetWidgetDirty(SLWW_SAVE_OSK_TITLE); |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1947 } |
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
|
1948 } 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
|
1949 /* 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
|
1950 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
|
1951 BuildFileList(); |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1952 } |
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
|
1953 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
|
1954 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1955 |
11352
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1956 case SLWW_CONTENT_DOWNLOAD: |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1957 if (!_network_available) { |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
1958 ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, 0, 0); |
11352
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1959 } else { |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1960 #if defined(ENABLE_NETWORK) |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1961 switch (_saveload_mode) { |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1962 default: NOT_REACHED(); |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1963 case SLD_LOAD_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break; |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1964 case SLD_LOAD_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break; |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1965 } |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1966 #endif |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1967 } |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1968 break; |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
1969 |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1970 case SLWW_DELETE_SELECTION: case SLWW_SAVE_GAME: // Delete, Save game |
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
|
1971 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
|
1972 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1973 } |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1974 |
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
|
1975 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
|
1976 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1977 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1978 this->HandleEditBox(SLWW_SAVE_OSK_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
|
1979 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1980 } |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1981 |
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
|
1982 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
|
1983 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1984 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
|
1985 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
|
1986 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
|
1987 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1988 |
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
|
1989 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
|
1990 if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) && |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1991 this->HandleEditBoxKey(SLWW_SAVE_OSK_TITLE, key, keycode, state) == HEBR_CONFIRM) { |
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
1992 this->HandleButtonClick(SLWW_SAVE_GAME); |
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
|
1993 } |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
1994 |
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
|
1995 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
|
1996 } |
8738
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
1997 |
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
|
1998 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
|
1999 { |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
2000 /* 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
|
2001 * 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
|
2002 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
|
2003 |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
2004 if (this->IsWidgetLowered(SLWW_DELETE_SELECTION)) { // Delete button clicked |
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
|
2005 if (!FiosDelete(this->text.buf)) { |
13419
ddfb6a69b9c3
(svn r17928) -Codechange: ShowErrorMessage() now takes the summary string before the details string.
alberth <alberth@openttd.org>
parents:
13418
diff
changeset
|
2006 ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, 0, 0); |
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
|
2007 } 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
|
2008 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
|
2009 /* 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
|
2010 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
|
2011 } |
723631ab4868
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium <rubidium@openttd.org>
parents:
8737
diff
changeset
|
2012 |
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
|
2013 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
|
2014 this->SetDirty(); |
10944
0f460411415a
(svn r15283) -Documentation: Apply some widget naming to the widget arrays.
belugas <belugas@openttd.org>
parents:
10934
diff
changeset
|
2015 } else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked |
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
|
2016 _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
|
2017 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
|
2018 |
3b7b689031d6
(svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium <rubidium@openttd.org>
parents:
9178
diff
changeset
|
2019 /* 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
|
2020 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
|
2021 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2022 } |
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
|
2023 |
13344
04b02b2cfa2b
(svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
rubidium <rubidium@openttd.org>
parents:
13340
diff
changeset
|
2024 virtual void OnResize() |
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
|
2025 { |
14037
ca29deba0f1a
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
alberth <alberth@openttd.org>
parents:
13996
diff
changeset
|
2026 this->vscroll.SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST); |
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
|
2027 } |
11352
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
2028 |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
2029 virtual void OnInvalidateData(int data) |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
2030 { |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
2031 BuildFileList(); |
62978bce3c1c
(svn r15702) -Feature(tte): direct content download 'links' in the play scenario/heightmap windows.
rubidium <rubidium@openttd.org>
parents:
11319
diff
changeset
|
2032 } |
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
|
2033 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2034 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
2035 static const WindowDesc _load_dialog_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13792
diff
changeset
|
2036 WDP_CENTER, 257, 294, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
2037 WC_SAVELOAD, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
2038 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
2039 _nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
2040 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2041 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
2042 static const WindowDesc _save_dialog_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13792
diff
changeset
|
2043 WDP_CENTER, 257, 320, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5750
diff
changeset
|
2044 WC_SAVELOAD, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13705
diff
changeset
|
2045 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13478
diff
changeset
|
2046 _nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11369
diff
changeset
|
2047 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2048 |
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
|
2049 /** 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
|
2050 * 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
|
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 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
|
2056 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
|
2057 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
|
2058 }; |
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
|
2059 |
8149
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
8144
diff
changeset
|
2060 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
|
2061 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2062 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
|
2063 |
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
|
2064 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
|
2065 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
|
2066 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
|
2067 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
|
2068 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
|
2069 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
|
2070 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
|
2071 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2072 |
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
|
2073 _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
|
2074 _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
|
2075 |
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
|
2076 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
|
2077 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2078 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6239
diff
changeset
|
2079 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
|
2080 { |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
13030
diff
changeset
|
2081 SetWindowDirty(WC_STATUS_BAR, 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
|
2082 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2083 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2084 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
|
2085 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2086 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
|
2087 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
|
2088 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
|
2089 _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
|
2090 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2091 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2092 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
|
2093 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
|
2094 _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
|
2095 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2096 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2097 #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
|
2098 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
|
2099 _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
|
2100 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2101 #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
|
2102 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2103 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
|
2104 _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
|
2105 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2106 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2107 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2108 _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
|
2109 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2110 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2111 } |