src/misc_gui.cpp
author peter1138
Sun, 03 Aug 2008 17:35:08 +0000
changeset 9834 7474149531c1
parent 9790 5d5c70e0334e
child 9897 4d9a6ff6703e
permissions -rw-r--r--
(svn r13977) -Codechange: Let ResizeWindowForWidget() handle hidden (zero height or zero width) widgets.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2167
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2167
diff changeset
     2
9111
48ce04029fe4 (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
parents: 9082
diff changeset
     3
/** @file misc_gui.cpp GUIs for a number of misc windows. */
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6197
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1879
diff changeset
     6
#include "openttd.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
     7
#include "heightmap.h"
1299
39c06aba09aa (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1274
diff changeset
     8
#include "debug.h"
6453
226bcddeba32 (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
parents: 6350
diff changeset
     9
#include "landscape.h"
5352
86fca6a41aa1 (svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents: 5320
diff changeset
    10
#include "newgrf.h"
7750
7afbef1235e0 (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents: 7521
diff changeset
    11
#include "newgrf_text.h"
2162
b98e430ffd10 (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 2159
diff changeset
    12
#include "saveload.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8107
diff changeset
    13
#include "tile_map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    15
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    16
#include "station_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    17
#include "textbuf_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    18
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    19
#include "gfx_func.h"
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8748
diff changeset
    20
#include "station_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    21
#include "command_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    22
#include "player_func.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    23
#include "player_base.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
#include "town.h"
5469
7edfc643abbc (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5447
diff changeset
    25
#include "network/network.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2134
diff changeset
    26
#include "variables.h"
8965
29a591456a2f (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 8916
diff changeset
    27
#include "cheat_func.h"
3890
e04bc34bc50c (svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents: 3798
diff changeset
    28
#include "train.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    29
#include "tgp.h"
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5893
diff changeset
    30
#include "cargotype.h"
6190
01a2b579b668 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6091
diff changeset
    31
#include "player_face.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8108
diff changeset
    32
#include "strings_func.h"
6929
56470c1b8a66 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6875
diff changeset
    33
#include "fileio.h"
4223
d4c9ef555f43 (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4217
diff changeset
    34
#include "fios.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8116
diff changeset
    35
#include "tile_cmd.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    36
#include "zoom_func.h"
8131
160939e24ed3 (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
parents: 8123
diff changeset
    37
#include "functions.h"
160939e24ed3 (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
parents: 8123
diff changeset
    38
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    39
#include "date_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8152
diff changeset
    40
#include "sound_func.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8208
diff changeset
    41
#include "string_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    42
#include "player_gui.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    43
#include "settings_type.h"
8787
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    44
#include "newgrf_cargo.h"
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8787
diff changeset
    45
#include "rail_gui.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    46
#include "tilehighlight_func.h"
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
    47
#include "querystring_gui.h"
9659
187142ff9b6c (svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents: 9652
diff changeset
    48
#include "player_base.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8116
diff changeset
    49
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    50
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    51
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    52
4223
d4c9ef555f43 (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4217
diff changeset
    53
/* Variables to display file lists */
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8144
diff changeset
    54
SaveLoadDialogMode _saveload_mode;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    56
1596
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
    57
static bool _fios_path_changed;
1594
00485cb74836 (svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents: 1578
diff changeset
    58
static bool _savegame_sort_dirty;
00485cb74836 (svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents: 1578
diff changeset
    59
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
static const Widget _land_info_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
    61
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9781
diff changeset
    62
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   299,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9781
diff changeset
    63
{      WWT_PANEL, RESIZE_BOTTOM,  COLOUR_GREY,     0,   299,    14,    99, 0x0,                            STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
    64
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
static const WindowDesc _land_info_desc = {
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9781
diff changeset
    68
	WDP_AUTO, WDP_AUTO, 300, 100, 300, 100,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
    69
	WC_LAND_INFO, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	_land_info_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    74
class LandInfoWindow : public Window {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    75
	enum {
9714
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
    76
		LAND_INFO_CENTERED_LINES   = 12,                       ///< Up to 12 centered lines
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    77
		LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    78
		LAND_INFO_LINE_END,
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    79
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    80
		LAND_INFO_LINE_BUFF_SIZE = 512,
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    81
	};
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
    82
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    83
public:
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    84
	char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
    85
9170
f7dbcf575828 (svn r13033) -Fix [FS#2003](r13029): land info tool wasn't working
smatz
parents: 9166
diff changeset
    86
	virtual void OnPaint()
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
    87
	{
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
    88
		this->DrawWidgets();
5583
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
    89
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
    90
		uint y = 21;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    91
		for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
    92
			if (StrEmpty(this->landinfo_data[i])) break;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    93
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9781
diff changeset
    94
			DoDrawStringCentered(150, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING);
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
    95
			y += i == 0 ? 16 : 12;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    96
		}
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    97
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
    98
		y += 6;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
    99
9648
c79160082c0f (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
parents: 9572
diff changeset
   100
		if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) {
c79160082c0f (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
parents: 9572
diff changeset
   101
			SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]);
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9781
diff changeset
   102
			DrawStringMultiCenter(150, y, STR_JUST_RAW_STRING, this->width - 4);
9648
c79160082c0f (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
parents: 9572
diff changeset
   103
		}
5583
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   104
	}
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   105
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   106
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
9652
0405e98d8e96 (svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents: 9648
diff changeset
   107
		Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
9413
7042a8ec3fa8 (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
parents: 9407
diff changeset
   108
		Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
5583
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   109
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   110
		Money old_money = p->player_money;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   111
		p->player_money = INT64_MAX;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   112
		CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   113
		p->player_money = old_money;
5583
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   114
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   115
		/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   116
		TileDesc td;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   117
		AcceptedCargo ac;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   118
9713
a1a2cbdb1090 (svn r13826) -Codechange: use 'INVALID_DATE' instead of '0' as placeholder in tile description
smatz
parents: 9693
diff changeset
   119
		td.build_date = INVALID_DATE;
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   120
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   121
		/* Most tiles have only one owner, but
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   122
		 *  - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   123
		 *  - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   124
		 */
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   125
		td.owner_type[0] = STR_01A7_OWNER; // At least one owner is displayed, though it might be "N/A".
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   126
		td.owner_type[1] = STR_NULL;       // STR_NULL results in skipping the owner
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   127
		td.owner_type[2] = STR_NULL;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   128
		td.owner_type[3] = STR_NULL;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   129
		td.owner[0] = OWNER_NONE;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   130
		td.owner[1] = OWNER_NONE;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   131
		td.owner[2] = OWNER_NONE;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   132
		td.owner[3] = OWNER_NONE;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   133
9714
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   134
		td.station_class = STR_NULL;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   135
		td.station_name = STR_NULL;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   136
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   137
		td.grf = NULL;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   138
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   139
		GetAcceptedCargo(tile, ac);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   140
		GetTileDesc(tile, &td);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   141
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   142
		uint line_nr = 0;
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   143
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   144
		/* Tiletype */
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   145
		SetDParam(0, td.dparam[0]);
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   146
		GetString(this->landinfo_data[line_nr], td.str, lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   147
		line_nr++;
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   148
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   149
		/* Up to four owners */
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   150
		for (uint i = 0; i < 4; i++) {
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   151
			if (td.owner_type[i] == STR_NULL) continue;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   152
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   153
			SetDParam(0, STR_01A6_N_A);
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   154
			if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   155
			GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   156
			line_nr++;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   157
		}
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   158
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   159
		/* Cost to clear */
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   160
		StringID str = STR_01A4_COST_TO_CLEAR_N_A;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   161
		if (CmdSucceeded(costclear)) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   162
			SetDParam(0, costclear.GetCost());
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   163
			str = STR_01A5_COST_TO_CLEAR;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   164
		}
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   165
		GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   166
		line_nr++;
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   167
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   168
		/* Location */
9648
c79160082c0f (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
parents: 9572
diff changeset
   169
		char tmp[16];
c79160082c0f (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
parents: 9572
diff changeset
   170
		snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   171
		SetDParam(0, TileX(tile));
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   172
		SetDParam(1, TileY(tile));
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   173
		SetDParam(2, TileHeight(tile));
9648
c79160082c0f (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
parents: 9572
diff changeset
   174
		SetDParamStr(3, tmp);
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   175
		GetString(this->landinfo_data[line_nr], STR_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   176
		line_nr++;
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   177
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   178
		/* Local authority */
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   179
		SetDParam(0, STR_01A9_NONE);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   180
		if (t != NULL && t->IsValid()) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   181
			SetDParam(0, STR_TOWN);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   182
			SetDParam(1, t->index);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   183
		}
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   184
		GetString(this->landinfo_data[line_nr], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   185
		line_nr++;
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   186
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   187
		/* Build date */
9713
a1a2cbdb1090 (svn r13826) -Codechange: use 'INVALID_DATE' instead of '0' as placeholder in tile description
smatz
parents: 9693
diff changeset
   188
		if (td.build_date != INVALID_DATE) {
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   189
			SetDParam(0, td.build_date);
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   190
			GetString(this->landinfo_data[line_nr], STR_BUILD_DATE, lastof(this->landinfo_data[line_nr]));
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   191
			line_nr++;
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   192
		}
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   193
9714
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   194
		/* Station class */
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   195
		if (td.station_class != STR_NULL) {
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   196
			SetDParam(0, td.station_class);
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   197
			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_CLASS, lastof(this->landinfo_data[line_nr]));
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   198
			line_nr++;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   199
		}
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   200
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   201
		/* Station type name */
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   202
		if (td.station_name != STR_NULL) {
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   203
			SetDParam(0, td.station_name);
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   204
			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_TYPE, lastof(this->landinfo_data[line_nr]));
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   205
			line_nr++;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   206
		}
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   207
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   208
		/* NewGRF name */
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   209
		if (td.grf != NULL) {
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   210
			SetDParamStr(0, td.grf);
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   211
			GetString(this->landinfo_data[line_nr], STR_TILEDESC_NEWGRF_NAME, lastof(this->landinfo_data[line_nr]));
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   212
			line_nr++;
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   213
		}
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   214
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   215
		assert(line_nr < LAND_INFO_CENTERED_LINES);
5d785e184f2d (svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz
parents: 9713
diff changeset
   216
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   217
		/* Mark last line empty */
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   218
		this->landinfo_data[line_nr][0] = '\0';
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   219
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   220
		/* Cargo acceptance is displayed in a extra multiline */
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   221
		char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   222
		bool found = false;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   223
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   224
		for (CargoID i = 0; i < NUM_CARGO; ++i) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   225
			if (ac[i] > 0) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   226
				/* Add a comma between each item. */
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   227
				if (found) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   228
					*strp++ = ',';
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   229
					*strp++ = ' ';
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   230
				}
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   231
				found = true;
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   232
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   233
				/* If the accepted value is less than 8, show it in 1/8:ths */
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   234
				if (ac[i] < 8) {
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   235
					SetDParam(0, ac[i]);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   236
					SetDParam(1, GetCargo(i)->name);
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   237
					strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   238
				} else {
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   239
					strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   240
				}
5583
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   241
			}
136d8764c7e6 (svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents: 5475
diff changeset
   242
		}
9322
cf7dc39f9576 (svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch
parents: 9319
diff changeset
   243
		if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   244
9572
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   245
		if (found) line_nr += 2;
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   246
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   247
		if (line_nr > 6) ResizeWindow(this, 0, 12 * (line_nr - 6));
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   248
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   249
		this->FindWindowPlacementAndResize(&_land_info_desc);
5704844d4218 (svn r13601) -Codechange: resize the Tile Info window when it is needed, make it better readable
smatz
parents: 9441
diff changeset
   250
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   251
#if defined(_DEBUG)
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   252
#	define LANDINFOD_LEVEL 0
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   253
#else
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   254
#	define LANDINFOD_LEVEL 1
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   255
#endif
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   256
		DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   257
		DEBUG(misc, LANDINFOD_LEVEL, "type_height  = %#x", _m[tile].type_height);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   258
		DEBUG(misc, LANDINFOD_LEVEL, "m1           = %#x", _m[tile].m1);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   259
		DEBUG(misc, LANDINFOD_LEVEL, "m2           = %#x", _m[tile].m2);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   260
		DEBUG(misc, LANDINFOD_LEVEL, "m3           = %#x", _m[tile].m3);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   261
		DEBUG(misc, LANDINFOD_LEVEL, "m4           = %#x", _m[tile].m4);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   262
		DEBUG(misc, LANDINFOD_LEVEL, "m5           = %#x", _m[tile].m5);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   263
		DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   264
		DEBUG(misc, LANDINFOD_LEVEL, "m7           = %#x", _me[tile].m7);
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
   265
#undef LANDINFOD_LEVEL
9155
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   266
	}
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   267
};
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   268
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   269
static void Place_LandInfo(TileIndex tile)
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   270
{
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   271
	DeleteWindowById(WC_LAND_INFO, 0);
8f090e825bf0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 9153
diff changeset
   272
	new LandInfoWindow(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
   275
void PlaceLandBlockInfo()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
{
1914
2b4b3c3a95b4 (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   277
	if (_cursor.sprite == SPR_CURSOR_QUERY) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
		_place_proc = Place_LandInfo;
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7859
diff changeset
   281
		SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
static const Widget _about_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   286
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   287
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   419,     0,    13, STR_015B_OPENTTD, STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   288
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   419,    14,   271, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   289
{      WWT_FRAME,   RESIZE_NONE,  COLOUR_GREY,     5,   414,    40,   245, STR_NULL,         STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   290
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
static const WindowDesc _about_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7321
diff changeset
   294
	WDP_CENTER, WDP_CENTER, 420, 272, 420, 272,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
   295
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
	_about_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
9227
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   300
struct AboutWindow : public Window {
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   301
	int scroll_height;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   302
	uint16 counter;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   303
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   304
	AboutWindow() : Window(&_about_desc)
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   305
	{
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   306
		this->counter = 5;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   307
		this->scroll_height = this->height - 40;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   308
		this->FindWindowPlacementAndResize(&_about_desc);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   309
	}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   310
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   311
	virtual void OnPaint()
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   312
	{
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   313
		static const char *credits[] = {
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   314
			/*************************************************************************
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   315
			 *                      maximum length of string which fits in window   -^*/
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   316
			"Original design by Chris Sawyer",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   317
			"Original graphics by Simon Foster",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   318
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   319
			"The OpenTTD team (in alphabetical order):",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   320
			"  Jean-Francois Claeys (Belugas) - GUI, newindustries and more",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   321
			"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   322
			"  Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   323
			"  Loïc Guilloux (glx) - General coding",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   324
			"  Christoph Elsenhans (frosch) - General coding",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   325
			"  Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   326
			"  Jonathan Coome (Maedhros) - High priest of the newGRF Temple",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   327
			"  Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   328
			"  Owen Rudge (orudge) - Forum host, OS/2 port",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   329
			"  Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   330
			"  Remko Bijker (Rubidium) - Lead coder and way more",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   331
			"  Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   332
			"  Zdenek Sojka (SmatZ) - Bug finder and fixer",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   333
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   334
			"Inactive Developers:",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   335
			"  Victor Fischer (Celestar) - Programming everywhere you need him to",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   336
			"  Tamás Faragó (Darkvater) - Ex-Lead coder",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   337
			"  Christoph Mallon (Tron) - Programmer, code correctness police",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   338
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   339
			"Retired Developers:",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   340
			"  Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   341
			"  Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   342
			"  Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   343
			"  Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   344
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   345
			"Special thanks go out to:",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   346
			"  Josef Drexler - For his great work on TTDPatch",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   347
			"  Marcin Grzegorczyk - For his documentation of TTD internals",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   348
			"  Petr Baudis (pasky) - Many patches, newGRF support",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   349
			"  Stefan Meißner (sign_de) - For his work on the console",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   350
			"  Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   351
			"  Cian Duffy (MYOB) - BeOS port / manual writing",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   352
			"  Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   353
			"  Richard Kempton (richK) - additional airports, initial TGP implementation",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   354
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   355
			"  Michael Blunck - Pre-Signals and Semaphores © 2003",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   356
			"  George - Canal/Lock graphics © 2003-2004",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   357
			"  David Dallaston - Tram tracks",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   358
			"  Marcin Grzegorczyk - Foundations for Tracks on Slopes",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   359
			"  All Translators - Who made OpenTTD a truly international game",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   360
			"  Bug Reporters - Without whom OpenTTD would still be full of bugs!",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   361
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   362
			"",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   363
			"And last but not least:",
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   364
			"  Chris Sawyer - For an amazing game!"
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   365
		};
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   366
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
   367
		this->DrawWidgets();
9227
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   368
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   369
		/* Show original copyright and revision version */
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   370
		DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   371
		DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   372
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   373
		int y = this->scroll_height;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   374
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   375
		/* Show all scrolling credits */
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   376
		for (uint i = 0; i < lengthof(credits); i++) {
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   377
			if (y >= 50 && y < (this->height - 40)) {
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   378
				DoDrawString(credits[i], 10, y, TC_BLACK);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   379
			}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   380
			y += 10;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   381
		}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   382
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   383
		/* If the last text has scrolled start a new from the start */
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   384
		if (y < 50) this->scroll_height = this->height - 40;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   385
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   386
		DoDrawStringCentered(210, this->height - 25, "Website: http://www.openttd.org", TC_BLACK);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   387
		DrawStringCentered(210, this->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   388
	}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   389
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   390
	virtual void OnTick()
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   391
	{
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   392
		if (--this->counter == 0) {
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   393
			this->counter = 5;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   394
			this->scroll_height--;
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   395
			this->SetDirty();
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   396
		}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   397
	}
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   398
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
   400
void ShowAboutWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	DeleteWindowById(WC_GAME_OPTIONS, 0);
9227
0163ad02f94c (svn r13093) -Codechange: make a class of AboutWindow.
glx
parents: 9226
diff changeset
   403
	new AboutWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
static const Widget _errmsg_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   407
{   WWT_CLOSEBOX,   RESIZE_NONE,    COLOUR_RED,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   408
{    WWT_CAPTION,   RESIZE_NONE,    COLOUR_RED,    11,   239,     0,    13, STR_00B2_MESSAGE, STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   409
{      WWT_PANEL,   RESIZE_BOTTOM,  COLOUR_RED,     0,   239,    14,    45, 0x0,              STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   410
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
static const Widget _errmsg_face_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   414
{   WWT_CLOSEBOX,   RESIZE_NONE,    COLOUR_RED,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   415
{    WWT_CAPTION,   RESIZE_NONE,    COLOUR_RED,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   416
{      WWT_PANEL,   RESIZE_BOTTOM,  COLOUR_RED,     0,   333,    14,   136, 0x0,                   STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   417
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   420
struct ErrmsgWindow : public Window {
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   421
private:
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   422
	uint duration;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   423
	uint64 decode_params[20];
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   424
	StringID message_1;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   425
	StringID message_2;
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   426
	bool show_player_face;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
9682
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   428
	int y[2];
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   429
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   430
public:
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   431
	ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_player_face) :
9301
3b20dfb6c4e8 (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium
parents: 9285
diff changeset
   432
			Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   433
			show_player_face(show_player_face)
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   434
	{
9413
7042a8ec3fa8 (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
parents: 9407
diff changeset
   435
		this->duration = _settings_client.gui.errmsg_duration;
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   436
		CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   437
		this->message_1 = msg1;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   438
		this->message_2 = msg2;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   439
		this->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
9682
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   440
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   441
		SwitchToErrorRefStack();
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   442
		RewindTextRefStack();
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   443
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   444
		assert(msg2 != INVALID_STRING_ID);
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   445
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   446
		int h2 = 3 + GetStringHeight(msg2, width - 2); // msg2 is printed first
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   447
		int h1 = (msg1 == INVALID_STRING_ID) ? 0 : 3 + GetStringHeight(msg1, width - 2);
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   448
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   449
		SwitchToNormalRefStack();
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   450
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   451
		int h = 15 + h1 + h2;
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   452
		height = max<int>(height, h);
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   453
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   454
		if (msg1 == INVALID_STRING_ID) {
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
   455
			/* only 1 line will be printed */
9682
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   456
			y[1] = (height - 15) / 2 + 15 - 5;
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   457
		} else {
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   458
			int over = (height - h) / 4;
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   459
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   460
			y[1] = 15 + h2 / 2 + 1 - 5 + over;
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   461
			y[0] = height - 3 - h1 / 2 - 5 - over;
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   462
		}
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   463
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   464
		this->FindWindowPlacementAndResize(width, height);
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   465
	}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   466
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   467
	virtual void OnPaint()
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   468
	{
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   469
		CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
   470
		this->DrawWidgets();
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   471
		CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   472
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   473
		/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages.
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   474
		 * 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
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   475
		 */
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   476
		SwitchToErrorRefStack();
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   477
		RewindTextRefStack();
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   478
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   479
		if (this->show_player_face) {
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   480
			const Player *p = GetPlayer((PlayerID)GetDParamX(this->decode_params, 2));
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   481
			DrawPlayerFace(p->face, p->player_color, 2, 16);
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   482
		}
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   483
9682
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   484
		DrawStringMultiCenter(this->width - 120, y[1], this->message_2, this->width - 2);
142c31e35bfa (svn r13787) -Codechange: resize the red error message box if needed
smatz
parents: 9659
diff changeset
   485
		if (this->message_1 != INVALID_STRING_ID) DrawStringMultiCenter(this->width - 120, y[0], this->message_1, this->width - 2);
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   486
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   487
		/* Switch back to the normal text ref. stack for NewGRF texts */
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   488
		SwitchToNormalRefStack();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
	}
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   490
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   491
	virtual void OnMouseLoop()
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   492
	{
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   493
		if (_right_button_down) delete this;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   494
	}
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   495
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   496
	virtual void OnHundredthTick()
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   497
	{
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   498
		if (--this->duration == 0) delete this;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   499
	}
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   500
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   501
	~ErrmsgWindow()
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   502
	{
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   503
		SetRedErrorSquare(0);
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   504
		extern StringID _switch_mode_errorstr;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   505
		_switch_mode_errorstr = INVALID_STRING_ID;
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   506
	}
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   507
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   508
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   509
	{
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   510
		if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   511
		delete this;
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   512
		return ES_HANDLED;
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   513
	}
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   514
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
	DeleteWindowById(WC_ERRMSG, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
9413
7042a8ec3fa8 (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
parents: 9407
diff changeset
   520
	if (!_settings_client.gui.errmsg_duration) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   522
	if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   523
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   524
	Point pt;
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   525
	const ViewPort *vp;
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   526
9265
ead232da4056 (svn r13131) -Codechange: make a class of the ErrmsgWindow.
glx
parents: 9228
diff changeset
   527
	if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= 8) {
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   528
		if ((x | y) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
			pt = RemapCoords2(x, y);
5120
1ff65e874ce3 (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5116
diff changeset
   530
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6197
diff changeset
   532
			/* move x pos to opposite corner */
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6492
diff changeset
   533
			pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
			pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - 260 : 20;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   535
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6197
diff changeset
   536
			/* move y pos to opposite corner */
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6492
diff changeset
   537
			pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
			pt.y = (pt.y < (_screen.height >> 1)) ? _screen.height - 80 : 100;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   539
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
			pt.x = (_screen.width - 240) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
			pt.y = (_screen.height - 46) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
		}
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   544
		new ErrmsgWindow(pt, 240, 46, msg_1, msg_2, _errmsg_widgets, false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
	} else {
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   546
		if ((x | y) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
			pt = RemapCoords2(x, y);
5120
1ff65e874ce3 (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5116
diff changeset
   548
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
   549
			pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334 / 2),  0, _screen.width  - 334);
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
   550
			pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top,  vp->zoom) + vp->top  - (137 / 2), 22, _screen.height - 137);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
		} else {
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
   552
			pt.x = (_screen.width  - 334) >> 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
			pt.y = (_screen.height - 137) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		}
9272
e64b518a7b54 (svn r13138) -Codechange: remove the need for IsWindowOfPrototype.
rubidium
parents: 9265
diff changeset
   555
		new ErrmsgWindow(pt, 334, 137, msg_1, msg_2, _errmsg_face_widgets, true);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6953
diff changeset
   559
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
{
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2475
diff changeset
   561
	StringID msg = STR_0805_ESTIMATED_COST;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
		msg = STR_0807_ESTIMATED_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
	}
7002
1bf6a62b0fcb (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
parents: 6998
diff changeset
   567
	SetDParam(0, cost);
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2475
diff changeset
   568
	ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6953
diff changeset
   571
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
	Point pt = RemapCoords(x,y,z);
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   574
	StringID msg = STR_0801_COST;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
		msg = STR_0803_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
	}
7002
1bf6a62b0fcb (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
parents: 6998
diff changeset
   580
	SetDParam(0, cost);
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   581
	AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6953
diff changeset
   584
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
1935
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   585
{
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   586
	Point pt = RemapCoords(x,y,z);
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   587
7002
1bf6a62b0fcb (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
parents: 6998
diff changeset
   588
	SetDParam(0, cost);
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   589
	AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   590
}
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   591
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   592
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   593
{
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   594
	Point pt = RemapCoords(x, y, z);
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   595
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   596
	assert(string != STR_NULL);
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   597
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   598
	SetDParam(0, percent);
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   599
	return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   600
}
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   601
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   602
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   603
{
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   604
	assert(string != STR_NULL);
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   605
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   606
	SetDParam(0, percent);
7014
533521754123 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7007
diff changeset
   607
	UpdateTextEffect(te_id, string);
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   608
}
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   609
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   610
void HideFillingPercent(TextEffectID te_id)
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   611
{
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6991
diff changeset
   612
	if (te_id != INVALID_TE_ID) RemoveTextEffect(te_id);
1935
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   613
}
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   614
2275
11a1dac70c45 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   615
static const Widget _tooltips_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
   616
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   199,     0,    31, 0x0, STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   617
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   620
struct TooltipsWindow : public Window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
{
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   622
	StringID string_id;
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   623
	byte paramcount;
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   624
	uint64 params[5];
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   625
	bool use_left_mouse_button;
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   626
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   627
	TooltipsWindow(int x, int y, int width, int height, const Widget *widget,
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   628
								 StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button) :
9301
3b20dfb6c4e8 (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium
parents: 9285
diff changeset
   629
			Window(x, y, width, height, WC_TOOLTIPS, widget)
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   630
	{
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   631
		this->string_id = str;
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   632
		assert(sizeof(this->params[0]) == sizeof(params[0]));
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   633
		memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   634
		this->paramcount = paramcount;
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   635
		this->use_left_mouse_button = use_left_mouse_button;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   637
		this->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   638
		this->widget[0].right = width;
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   639
		this->widget[0].bottom = height;
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   640
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   641
		FindWindowPlacementAndResize(width, height);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
	}
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   643
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   644
	virtual void OnPaint()
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   645
	{
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   646
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0);
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   647
		GfxFillRect(1, 1, this->width - 2, this->height - 2, 0x44);
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   648
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   649
		for (uint arg = 0; arg < this->paramcount; arg++) {
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   650
			SetDParam(arg, this->params[arg]);
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   651
		}
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   652
		DrawStringMultiCenter((this->width >> 1), (this->height >> 1) - 5, this->string_id, this->width - 2);
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   653
	}
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   654
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   655
	virtual void OnMouseLoop()
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   656
	{
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   657
		/* We can show tooltips while dragging tools. These are shown as long as
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   658
		 * we are dragging the tool. Normal tooltips work with rmb */
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   659
		if (this->use_left_mouse_button ? !_left_button_down : !_right_button_down) delete this;
9186
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   660
	}
ff18bee53ee4 (svn r13049) -Codechange: make a class of the TooltipsWindow.
rubidium
parents: 9179
diff changeset
   661
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   663
/** Shows a tooltip
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   664
 * @param str String to be displayed
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   665
 * @param paramcount number of params to deal with
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   666
 * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   667
 * @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   668
 */
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   669
void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
{
4884
94dd5df0d584 (svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents: 4850
diff changeset
   671
	DeleteWindowById(WC_TOOLTIPS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   673
	if (str == STR_NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   675
	for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   676
	char buffer[512];
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4909
diff changeset
   677
	GetString(buffer, str, lastof(buffer));
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   678
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   679
	Dimension br = GetStringBoundingBox(buffer);
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   680
	br.width += 6; br.height += 4; // increase slightly to have some space around the box
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
4558
0c21ecb2b34e (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   682
	/* Cut tooltip length to 200 pixels max, wrap to new line if longer */
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   683
	if (br.width > 200) {
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   684
		br.height += ((br.width - 4) / 176) * 10;
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   685
		br.width = 200;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
4558
0c21ecb2b34e (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   688
	/* Correctly position the tooltip position, watch out for window and cursor size
0c21ecb2b34e (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   689
	 * Clamp value to below main toolbar and above statusbar. If tooltip would
0c21ecb2b34e (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   690
	 * go below window, flip it so it is shown above the cursor */
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   691
	int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   692
	if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   693
	int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
9781
31e0e461d7bf (svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch
parents: 9752
diff changeset
   695
	new TooltipsWindow(x, y, br.width, br.height, _tooltips_widgets, str, paramcount, params, use_left_mouse_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
8846
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   699
static int DrawStationCoverageText(const AcceptedCargo cargo,
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   700
	int str_x, int str_y, StationCoverageType sct, bool supplies)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
{
5038
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   702
	bool first = true;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   703
9648
c79160082c0f (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
parents: 9572
diff changeset
   704
	char string[512];
c79160082c0f (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
parents: 9572
diff changeset
   705
	char *b = InlineString(string, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
7241
7fd23b6f6713 (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
parents: 7138
diff changeset
   707
	for (CargoID i = 0; i < NUM_CARGO; i++) {
9648
c79160082c0f (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
parents: 9572
diff changeset
   708
		if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
7241
7fd23b6f6713 (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
parents: 7138
diff changeset
   709
		switch (sct) {
7fd23b6f6713 (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
parents: 7138
diff changeset
   710
			case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
7fd23b6f6713 (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
parents: 7138
diff changeset
   711
			case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
7fd23b6f6713 (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
parents: 7138
diff changeset
   712
			case SCT_ALL: break;
7fd23b6f6713 (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
parents: 7138
diff changeset
   713
			default: NOT_REACHED();
7fd23b6f6713 (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
parents: 7138
diff changeset
   714
		}
8916
bd6e75b4381d (svn r12686) -Fix: MSVC signed/unsigned warning
glx
parents: 8846
diff changeset
   715
		if (cargo[i] >= (supplies ? 1U : 8U)) {
5038
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   716
			if (first) {
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   717
				first = false;
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   718
			} else {
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   719
				/* Add a comma if this is not the first item */
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   720
				*b++ = ',';
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   721
				*b++ = ' ';
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   722
			}
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5893
diff changeset
   723
			b = InlineString(b, GetCargo(i)->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
5038
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   727
	/* If first is still true then no cargo is accepted */
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   728
	if (first) b = InlineString(b, STR_00D0_NOTHING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
5038
12fd4db0cdb5 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   730
	*b = '\0';
8041
9483d3e46b3e (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8036
diff changeset
   731
9483d3e46b3e (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8036
diff changeset
   732
	/* Make sure we detect any buffer overflow */
9648
c79160082c0f (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
parents: 9572
diff changeset
   733
	assert(b < endof(string));
8041
9483d3e46b3e (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8036
diff changeset
   734
9648
c79160082c0f (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
parents: 9572
diff changeset
   735
	SetDParamStr(0, string);
c79160082c0f (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
parents: 9572
diff changeset
   736
	return DrawStringMultiLine(str_x, str_y, STR_JUST_RAW_STRING, 144);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
8846
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   739
/**
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   740
 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   741
 * @param sx x position where the string is to be drawn
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   742
 * @param sy y position where the string is to be drawn
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   743
 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   744
 * @param rad radius around selected tile(s) to be searched
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   745
 * @param supplies if supplied cargos should be drawn, else accepted cargos
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   746
 * @return Returns the y value below the string that was drawn
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   747
 */
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   748
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
7321
f91bdca345e8 (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7266
diff changeset
   749
{
2873
64296f203ac4 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   750
	TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
8846
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   751
	AcceptedCargo cargo;
2873
64296f203ac4 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   752
	if (tile < MapSize()) {
8846
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   753
		if (supplies) {
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   754
			GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   755
		} else {
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   756
			GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   757
		}
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8831
diff changeset
   758
		return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
	}
8423
0c0f0370620b (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8349
diff changeset
   760
0c0f0370620b (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8349
diff changeset
   761
	return sy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
   764
void CheckRedrawStationCoverage(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
{
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   766
	if (_thd.dirty & 1) {
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   767
		_thd.dirty &= ~1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   772
/* Delete a character at the caret position in a text buf.
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   773
 * If backspace is set, delete the character before the caret,
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   774
 * else delete the character after it. */
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   775
static void DelChar(Textbuf *tb, bool backspace)
911
7ccc33888a33 (svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents: 910
diff changeset
   776
{
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   777
	WChar c;
6214
1f361897ed7f (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
parents: 6211
diff changeset
   778
	char *s = tb->buf + tb->caretpos;
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   779
6214
1f361897ed7f (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
parents: 6211
diff changeset
   780
	if (backspace) s = Utf8PrevChar(s);
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   781
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9354
diff changeset
   782
	uint16 len = (uint16)Utf8Decode(&c, s);
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   783
	uint width = GetCharacterWidth(FS_NORMAL, c);
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   784
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   785
	tb->width  -= width;
6214
1f361897ed7f (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
parents: 6211
diff changeset
   786
	if (backspace) {
1f361897ed7f (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
parents: 6211
diff changeset
   787
		tb->caretpos   -= len;
1f361897ed7f (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
parents: 6211
diff changeset
   788
		tb->caretxoffs -= width;
1f361897ed7f (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
parents: 6211
diff changeset
   789
	}
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   790
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   791
	/* Move the remaining characters over the marker */
6214
1f361897ed7f (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
parents: 6211
diff changeset
   792
	memmove(s, s + len, tb->length - (s - tb->buf) - len + 1);
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   793
	tb->length -= len;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   794
}
911
7ccc33888a33 (svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents: 910
diff changeset
   795
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   796
/**
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   797
 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace'
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   798
 * The character is delete from the position the caret is at
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   799
 * @param tb Textbuf type to be changed
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   800
 * @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
7372
6fac48ff7c4d (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7346
diff changeset
   801
 * @return Return true on successful change of Textbuf, or false otherwise
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   802
 */
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   803
bool DeleteTextBufferChar(Textbuf *tb, int delmode)
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   804
{
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   805
	if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   806
		DelChar(tb, true);
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   807
		return true;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   808
	} else if (delmode == WKC_DELETE && tb->caretpos < tb->length) {
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   809
		DelChar(tb, false);
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   810
		return true;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   811
	}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   812
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   813
	return false;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   814
}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   815
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   816
/**
1879
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   817
 * Delete every character in the textbuffer
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   818
 * @param tb Textbuf buffer to be emptied
1879
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   819
 */
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   820
void DeleteTextBufferAll(Textbuf *tb)
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   821
{
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   822
	memset(tb->buf, 0, tb->maxlength);
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   823
	tb->length = tb->width = 0;
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   824
	tb->caretpos = tb->caretxoffs = 0;
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   825
}
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   826
b037d07154c6 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   827
/**
3459
c6096d4423aa (svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents: 3458
diff changeset
   828
 * Insert a character to a textbuffer. If maxwidth of the Textbuf is zero,
c6096d4423aa (svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents: 3458
diff changeset
   829
 * we don't care about the visual-length but only about the physical
3458
26360c9a3743 (svn r4301) - Fix: the maxlength parameter of Textbuf is supposed to be the size of the buffer (so length of string + '\0'), but in the code it was a mix of both. It didn't cause any problems though, only an occasionaly one-less character than allowed. (thanks Tron for noticing)
Darkvater
parents: 3421
diff changeset
   830
 * length of the string
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   831
 * @param tb Textbuf type to be changed
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   832
 * @param key Character to be inserted
7372
6fac48ff7c4d (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7346
diff changeset
   833
 * @return Return true on successful change of Textbuf, or false otherwise
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   834
 */
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   835
bool InsertTextBufferChar(Textbuf *tb, WChar key)
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   836
{
3798
b1f5290b36b1 (svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents: 3719
diff changeset
   837
	const byte charwidth = GetCharacterWidth(FS_NORMAL, key);
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9354
diff changeset
   838
	uint16 len = (uint16)Utf8CharLen(key);
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   839
	if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) {
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   840
		memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1);
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   841
		Utf8Encode(tb->buf + tb->caretpos, key);
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   842
		tb->length += len;
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   843
		tb->width  += charwidth;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   844
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   845
		tb->caretpos   += len;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   846
		tb->caretxoffs += charwidth;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   847
		return true;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   848
	}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   849
	return false;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   850
}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   851
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   852
/**
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   853
 * Handle text navigation with arrow keys left/right.
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   854
 * This defines where the caret will blink and the next characer interaction will occur
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   855
 * @param tb Textbuf type where navigation occurs
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   856
 * @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
7372
6fac48ff7c4d (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7346
diff changeset
   857
 * @return Return true on successful change of Textbuf, or false otherwise
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   858
 */
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   859
bool MoveTextBufferPos(Textbuf *tb, int navmode)
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   860
{
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   861
	switch (navmode) {
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   862
		case WKC_LEFT:
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   863
			if (tb->caretpos != 0) {
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   864
				WChar c;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   865
				const char *s = Utf8PrevChar(tb->buf + tb->caretpos);
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   866
				Utf8Decode(&c, s);
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   867
				tb->caretpos    = s - tb->buf; // -= (tb->buf + tb->caretpos - s)
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   868
				tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c);
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   869
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   870
				return true;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   871
			}
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   872
			break;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   873
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   874
		case WKC_RIGHT:
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   875
			if (tb->caretpos < tb->length) {
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   876
				WChar c;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   877
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9354
diff changeset
   878
				tb->caretpos   += (uint16)Utf8Decode(&c, tb->buf + tb->caretpos);
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   879
				tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c);
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   880
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   881
				return true;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   882
			}
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   883
			break;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   884
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   885
		case WKC_HOME:
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   886
			tb->caretpos = 0;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   887
			tb->caretxoffs = 0;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   888
			return true;
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   889
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   890
		case WKC_END:
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   891
			tb->caretpos = tb->length;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
   892
			tb->caretxoffs = tb->width;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   893
			return true;
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   894
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   895
		default:
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
   896
			break;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   897
	}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   898
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   899
	return false;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   900
}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   901
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   902
/**
4948
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   903
 * Initialize the textbuffer by supplying it the buffer to write into
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   904
 * and the maximum length of this buffer
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   905
 * @param tb Textbuf type which is getting initialized
4948
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   906
 * @param buf the buffer that will be holding the data for input
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   907
 * @param maxlength maximum length in characters of this buffer
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   908
 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer
4958
5bf9f412940a (svn r6957) -Cleanup: comments, coding style
Darkvater
parents: 4955
diff changeset
   909
 * cannot grow, even if maxlength would allow because there is space. A length
5bf9f412940a (svn r6957) -Cleanup: comments, coding style
Darkvater
parents: 4955
diff changeset
   910
 * of zero '0' means the buffer is only restricted by maxlength */
4948
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   911
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth)
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   912
{
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   913
	tb->buf = (char*)buf;
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   914
	tb->maxlength = maxlength;
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   915
	tb->maxwidth  = maxwidth;
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   916
	tb->caret = true;
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   917
	UpdateTextBufferSize(tb);
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   918
}
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   919
22ff05c1a3b1 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   920
/**
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   921
 * Update Textbuf type with its actual physical character and screenlength
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   922
 * Get the count of characters in the string as well as the width in pixels.
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   923
 * Useful when copying in a larger amount of text at once
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6453
diff changeset
   924
 * @param tb Textbuf type which length is calculated
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   925
 */
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   926
void UpdateTextBufferSize(Textbuf *tb)
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   927
{
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   928
	const char *buf = tb->buf;
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   929
	WChar c = Utf8Consume(&buf);
2630
7206058a7e82 (svn r3172) static, const
tron
parents: 2559
diff changeset
   930
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   931
	tb->width = 0;
5447
4bdf874190e8 (svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents: 5431
diff changeset
   932
	tb->length = 0;
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   933
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   934
	for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) {
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5079
diff changeset
   935
		tb->width += GetCharacterWidth(FS_NORMAL, c);
5447
4bdf874190e8 (svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents: 5431
diff changeset
   936
		tb->length += Utf8CharLen(c);
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   937
	}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   938
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   939
	tb->caretpos = tb->length;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   940
	tb->caretxoffs = tb->width;
911
7ccc33888a33 (svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents: 910
diff changeset
   941
}
7ccc33888a33 (svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents: 910
diff changeset
   942
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   943
bool HandleCaret(Textbuf *tb)
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   944
{
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   945
	/* caret changed? */
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   946
	bool b = !!(_caret_timer & 0x20);
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   947
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   948
	if (b != tb->caret) {
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   949
		tb->caret = b;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   950
		return true;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   951
	}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   952
	return false;
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   953
}
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   954
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   955
int QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
{
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   957
	state = Window::ES_HANDLED;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   958
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   959
	switch (keycode) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   960
		case WKC_ESC: return 2;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   961
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   962
		case WKC_RETURN: case WKC_NUM_ENTER: return 1;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   963
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   964
		case (WKC_CTRL | 'V'):
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   965
			if (InsertTextBufferClipboard(&this->text)) w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   966
			break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   967
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   968
		case (WKC_CTRL | 'U'):
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   969
			DeleteTextBufferAll(&this->text);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   970
			w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   971
			break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   972
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   973
		case WKC_BACKSPACE: case WKC_DELETE:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   974
			if (DeleteTextBufferChar(&this->text, keycode)) w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   975
			break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   976
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   977
		case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   978
			if (MoveTextBufferPos(&this->text, keycode)) w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   979
			break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   980
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   981
		default:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   982
			if (IsValidChar(key, this->afilter)) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   983
				if (InsertTextBufferChar(&this->text, key)) w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   984
			} else { // key wasn't caught. Continue only if standard entry specified
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
   985
				state = (this->afilter == CS_ALPHANUMERAL) ? Window::ES_HANDLED : Window::ES_NOT_HANDLED;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   986
			}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   987
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   988
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   989
	return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   992
void QueryString::HandleEditBox(Window *w, int wid)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   993
{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   994
	if (HandleCaret(&this->text)) w->InvalidateWidget(wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   995
}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   996
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
   997
void QueryString::DrawEditBox(Window *w, int wid)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   998
{
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   999
	const Widget *wi = &w->widget[wid];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1000
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8715
diff changeset
  1001
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8715
diff changeset
  1002
5639
c9c55071b0ea (svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents: 5596
diff changeset
  1003
	GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
c9c55071b0ea (svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents: 5596
diff changeset
  1004
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1005
	DrawPixelInfo dpi;
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1006
	int delta;
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1007
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1008
	/* Limit the drawing of the string inside the widget boundaries */
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1009
	if (!FillDrawPixelInfo(&dpi,
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1010
			wi->left + 4,
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1011
			wi->top + 1,
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1012
			wi->right - wi->left - 4,
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1013
			wi->bottom - wi->top - 1)) {
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1014
		return;
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1015
	}
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1016
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1017
	DrawPixelInfo *old_dpi = _cur_dpi;
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1018
	_cur_dpi = &dpi;
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1019
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1020
	/* We will take the current widget length as maximum width, with a small
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1021
	 * space reserved at the end for the caret to show */
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1022
	const Textbuf *tb = &this->text;
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1023
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1024
	delta = (wi->right - wi->left) - tb->width - 10;
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1025
	if (delta > 0) delta = 0;
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1026
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1027
	if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1028
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1029
	DoDrawString(tb->buf, delta, 0, TC_YELLOW);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1030
	if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE);
4955
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1031
1ffc9ce449a8 (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
  1032
	_cur_dpi = old_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1035
int QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state)
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1036
{
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1037
	return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1038
}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1039
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1040
void QueryStringBaseWindow::HandleEditBox(int wid)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1041
{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1042
	this->QueryString::HandleEditBox(this, wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1043
}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1044
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1045
void QueryStringBaseWindow::DrawEditBox(int wid)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1046
{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1047
	this->QueryString::DrawEditBox(this, wid);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1048
}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1049
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1050
enum QueryStringWidgets {
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1051
	QUERY_STR_WIDGET_TEXT = 3,
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1052
	QUERY_STR_WIDGET_CANCEL,
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1053
	QUERY_STR_WIDGET_OK
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1054
};
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1055
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1056
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1057
struct QueryStringWindow : public QueryStringBaseWindow
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
{
9226
8d5b5e23c9c9 (svn r13092) -Fix (r13042): don't add a variable in a subclass when the parent class already have it
glx
parents: 9186
diff changeset
  1059
	QueryStringWindow(const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(desc)
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1060
	{
9226
8d5b5e23c9c9 (svn r13092) -Fix (r13042): don't add a variable in a subclass when the parent class already have it
glx
parents: 9186
diff changeset
  1061
		this->parent = parent;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1062
		SetBit(_no_scroll, SCROLL_EDIT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1063
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1064
		this->FindWindowPlacementAndResize(desc);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1065
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1066
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1067
	virtual void OnPaint()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1068
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1069
		SetDParam(0, this->caption);
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
  1070
		this->DrawWidgets();
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1071
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1072
		this->DrawEditBox(QUERY_STR_WIDGET_TEXT);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1073
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1074
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1075
	void OnOk()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1076
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1077
		if (this->orig == NULL || strcmp(this->text.buf, this->orig) != 0) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1078
			/* If the parent is NULL, the editbox is handled by general function
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1079
			 * HandleOnEditText */
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1080
			if (this->parent != NULL) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1081
				this->parent->OnQueryTextFinished(this->text.buf);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1082
			} else {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1083
				HandleOnEditText(this->text.buf);
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1084
			}
9228
defd5984cb60 (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
parents: 9227
diff changeset
  1085
			this->handled = true;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1086
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1087
	}
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1088
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1089
	virtual void OnClick(Point pt, int widget)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1090
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1091
		switch (widget) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1092
			case QUERY_STR_WIDGET_TEXT:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1093
				ShowOnScreenKeyboard(this, QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1094
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1095
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1096
			case QUERY_STR_WIDGET_OK:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1097
				this->OnOk();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1098
				/* Fallthrough */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1099
			case QUERY_STR_WIDGET_CANCEL:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1100
				delete this;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1101
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1102
		}
9166
dce886fc5eeb (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
parents: 9164
diff changeset
  1103
	}
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1104
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1105
	virtual void OnMouseLoop()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1106
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1107
		this->HandleEditBox(QUERY_STR_WIDGET_TEXT);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1108
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1109
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1110
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1111
	{
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1112
		EventState state;
235e5e2d7f55 (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
parents: 9273
diff changeset
  1113
		switch (this->HandleEditBoxKey(QUERY_STR_WIDGET_TEXT, key, keycode, state)) {
9399
3090d36f3436 (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz
parents: 9394
diff changeset
  1114
			default: NOT_REACHED();
3090d36f3436 (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz
parents: 9394
diff changeset
  1115
			case 0: {
3090d36f3436 (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz
parents: 9394
diff changeset
  1116
				Window *osk = FindWindowById(WC_OSK, 0);
3090d36f3436 (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz
parents: 9394
diff changeset
  1117
				if (osk != NULL && osk->parent == this) osk->OnInvalidateData();
3090d36f3436 (svn r13310) -Fix: invalidate OSK when parent editbox changes (from keyboard)
smatz
parents: 9394
diff changeset
  1118
			} break;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1119
			case 1: this->OnOk(); // Enter pressed, confirms change
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1120
			/* FALL THROUGH */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1121
			case 2: delete this; break; // ESC pressed, closes window, abandons changes
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1122
		}
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1123
		return state;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1124
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1125
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1126
	~QueryStringWindow()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1127
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1128
		if (!this->handled && this->parent != NULL) {
9393
5dfefab66454 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz
parents: 9390
diff changeset
  1129
			Window *parent = this->parent;
5dfefab66454 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz
parents: 9390
diff changeset
  1130
			this->parent = NULL; // so parent doesn't try to delete us again
5dfefab66454 (svn r13304) -Fix (r13042): possible double free (showed up in r13092)
smatz
parents: 9390
diff changeset
  1131
			parent->OnQueryTextFinished(NULL);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1132
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1133
		ClrBit(_no_scroll, SCROLL_EDIT);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1134
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1135
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1136
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
static const Widget _query_string_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1138
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1139
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   259,     0,    13, STR_012D,        STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1140
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   259,    14,    29, 0x0,             STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1141
{    WWT_EDITBOX,   RESIZE_NONE,  COLOUR_GREY,     2,   257,    16,    27, 0x0,             STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1142
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   129,    30,    41, STR_012E_CANCEL, STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1143
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   130,   259,    30,    41, STR_012F_OK,     STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
  1144
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1145
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1146
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1147
static const WindowDesc _query_string_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7321
diff changeset
  1148
	190, 219, 260, 42, 260, 42,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
  1149
	WC_QUERY_STRING, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
  1150
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1151
	_query_string_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1152
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1153
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1154
/** Show a query popup window with a textbox in it.
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1155
 * @param str StringID for the text shown in the textbox
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1156
 * @param caption StringID of text shown in caption of querywindow
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1157
 * @param maxlen maximum length in characters allowed. If bit 12 is set we
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9301
diff changeset
  1158
 *               will not check the resulting string against to original string to return success
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1159
 * @param maxwidth maximum width in pixels allowed
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1160
 * @param parent pointer to a Window that will handle the events (ok/cancel) of this
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9301
diff changeset
  1161
 *        window. If NULL, results are handled by global function HandleOnEditText
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1162
 * @param afilter filters out unwanted character input */
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5429
diff changeset
  1163
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
{
1390
e7cdf3ce0fb6 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1165
	uint realmaxlen = maxlen & ~0x1000;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1166
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1168
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1170
	QueryStringWindow *w = new QueryStringWindow(&_query_string_desc, parent);
1386
0de4f8541aea (svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents: 1363
diff changeset
  1171
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1172
	assert(realmaxlen < lengthof(w->edit_str_buf));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1173
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1174
	GetString(w->edit_str_buf, str, lastof(w->edit_str_buf));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1175
	w->edit_str_buf[realmaxlen - 1] = '\0';
596
a787fc8fba4a (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1176
a787fc8fba4a (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1177
	if (maxlen & 0x1000) {
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1178
		w->orig = NULL;
1386
0de4f8541aea (svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents: 1363
diff changeset
  1179
	} else {
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1180
		strecpy(w->orig_str_buf, w->edit_str_buf, lastof(w->orig_str_buf));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1181
		w->orig = w->orig_str_buf;
1386
0de4f8541aea (svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents: 1363
diff changeset
  1182
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1184
	w->LowerWidget(QUERY_STR_WIDGET_TEXT);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1185
	w->caption = caption;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1186
	w->afilter = afilter;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1187
	InitializeTextBuffer(&w->text, w->edit_str_buf, realmaxlen, maxwidth);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1188
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1190
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1191
enum QueryWidgets {
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1192
	QUERY_WIDGET_CAPTION = 1,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1193
	QUERY_WIDGET_NO = 3,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1194
	QUERY_WIDGET_YES
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1195
};
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1196
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1197
/**
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1198
 * Window used for asking the user a YES/NO question.
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1199
 */
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1200
struct QueryWindow : public Window {
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1201
	QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1202
	uint64 params[10];       ///< local copy of _decode_parameters
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1203
	StringID message;        ///< message shown for query window
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1204
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1205
	QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1206
	{
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1207
		if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1208
		this->parent = parent;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1209
		this->left = parent->left + (parent->width / 2) - (this->width / 2);
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1210
		this->top = parent->top + (parent->height / 2) - (this->height / 2);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1211
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1212
		/* Create a backup of the variadic arguments to strings because it will be
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1213
		 * overridden pretty often. We will copy these back for drawing */
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1214
		CopyOutDParam(this->params, 0, lengthof(this->params));
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1215
		this->widget[QUERY_WIDGET_CAPTION].data = caption;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1216
		this->message    = message;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1217
		this->proc       = callback;
9178
3235f895bf12 (svn r13041) -Fix: calling a virtual function on a not fully constructed object is bound to cause errors.
rubidium
parents: 9176
diff changeset
  1218
3235f895bf12 (svn r13041) -Fix: calling a virtual function on a not fully constructed object is bound to cause errors.
rubidium
parents: 9176
diff changeset
  1219
		this->FindWindowPlacementAndResize(desc);
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1220
	}
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1221
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1222
	~QueryWindow()
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1223
	{
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1224
		if (this->proc != NULL) this->proc(this->parent, false);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1225
	}
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1226
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1227
	virtual void OnPaint()
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1228
	{
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1229
		CopyInDParam(0, this->params, lengthof(this->params));
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
  1230
		this->DrawWidgets();
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1231
		CopyInDParam(0, this->params, lengthof(this->params));
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1232
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1233
		DrawStringMultiCenter(this->width / 2, (this->height / 2) - 10, this->message, this->width - 2);
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1234
	}
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1235
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1236
	virtual void OnClick(Point pt, int widget)
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1237
	{
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1238
		switch (widget) {
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1239
			case QUERY_WIDGET_YES: {
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1240
				/* in the Generate New World window, clicking 'Yes' causes
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1241
				 * DeleteNonVitalWindows() to be called - we shouldn't be in a window then */
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1242
				QueryCallbackProc *proc = this->proc;
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1243
				Window *parent = this->parent;
9394
019d83716697 (svn r13305) -Fix (r13039): Confirmation window sent both yes and no answers instead of just yes.
peter1138
parents: 9393
diff changeset
  1244
				/* Prevent the destructor calling the callback function */
019d83716697 (svn r13305) -Fix (r13039): Confirmation window sent both yes and no answers instead of just yes.
peter1138
parents: 9393
diff changeset
  1245
				this->proc = NULL;
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1246
				delete this;
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1247
				if (proc != NULL) {
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1248
					proc(parent, true);
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1249
					proc = NULL;
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1250
				}
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1251
			} break;
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1252
			case QUERY_WIDGET_NO:
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1253
				delete this;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1254
				break;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1255
		}
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1256
	}
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1257
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1258
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1259
	{
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1260
		/* ESC closes the window, Enter confirms the action */
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1261
		switch (keycode) {
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1262
			case WKC_RETURN:
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1263
			case WKC_NUM_ENTER:
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1264
				if (this->proc != NULL) {
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1265
					this->proc(this->parent, true);
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1266
					this->proc = NULL;
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1267
				}
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1268
				/* Fallthrough */
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1269
			case WKC_ESC:
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1270
				delete this;
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1271
				return ES_HANDLED;
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1272
		}
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1273
		return ES_NOT_HANDLED;
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1274
	}
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1275
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1276
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1277
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1278
static const Widget _query_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1279
{  WWT_CLOSEBOX, RESIZE_NONE,  COLOUR_RED,      0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1280
{   WWT_CAPTION, RESIZE_NONE,  COLOUR_RED,     11, 209,   0,  13, STR_NULL,        STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1281
{     WWT_PANEL, RESIZE_NONE,  COLOUR_RED,      0, 209,  14,  81, 0x0, /*OVERRIDE*/STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1282
{WWT_PUSHTXTBTN, RESIZE_NONE,  COLOUR_YELLOW,  20,  90,  62,  73, STR_00C9_NO,     STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1283
{WWT_PUSHTXTBTN, RESIZE_NONE,  COLOUR_YELLOW, 120, 190,  62,  73, STR_00C8_YES,    STR_NULL},
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1284
{   WIDGETS_END },
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1285
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1286
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1287
static const WindowDesc _query_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7321
diff changeset
  1288
	WDP_CENTER, WDP_CENTER, 210, 82, 210, 82,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
  1289
	WC_CONFIRM_POPUP_QUERY, WC_NONE,
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1290
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1291
	_query_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1292
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1293
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1294
/** Show a modal confirmation window with standard 'yes' and 'no' buttons
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1295
 * The window is aligned to the centre of its parent.
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1296
 * NOTE: You cannot use BindCString as parameter for this window!
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1297
 * @param caption string shown as window caption
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1298
 * @param message string that will be shown for the window
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1299
 * @param parent pointer to parent window, if this pointer is NULL the parent becomes
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
  1300
 * the main window WC_MAIN_WINDOW
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1301
 * @param callback callback function pointer to set in the window descriptor
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1302
 */
9319
141ca3009ac2 (svn r13191) -Fix: segfault after confirming query subwindow in the Generate New World window
smatz
parents: 9317
diff changeset
  1303
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1304
{
9176
16ab8142a402 (svn r13039) -Codechange: make a class of the Query window.
rubidium
parents: 9170
diff changeset
  1305
	new QueryWindow(&_query_desc, caption, message, parent, callback);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1306
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1307
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1308
5079
15816766b4ee (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1309
static const Widget _load_dialog_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1310
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1311
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1312
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1313
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   128,   256,    14,    25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1314
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,     0,   256,    26,    47, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1315
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   256,    48,   153, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1316
{ WWT_PUSHIMGBTN,     RESIZE_LR,  COLOUR_GREY,   245,   256,    48,    59, SPR_HOUSE_ICON,   STR_SAVELOAD_HOME_BUTTON},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1317
{      WWT_INSET,     RESIZE_RB,  COLOUR_GREY,     2,   243,    50,   151, 0x0,              STR_400A_LIST_OF_DRIVES_DIRECTORIES},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1318
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   245,   256,    60,   141, 0x0,              STR_0190_SCROLL_BAR_SCROLLS_LIST},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1319
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   245,   256,   142,   153, 0x0,              STR_RESIZE_BUTTON},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1320
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1321
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1322
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1323
static const Widget _save_dialog_widgets[] = {
9752
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1324
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1325
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1326
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1327
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   128,   256,    14,    25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1328
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,     0,   256,    26,    47, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1329
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   256,    48,   151, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1330
{ WWT_PUSHIMGBTN,     RESIZE_LR,  COLOUR_GREY,   245,   256,    48,    59, SPR_HOUSE_ICON,   STR_SAVELOAD_HOME_BUTTON},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1331
{      WWT_INSET,     RESIZE_RB,  COLOUR_GREY,     2,   243,    50,   150, 0x0,              STR_400A_LIST_OF_DRIVES_DIRECTORIES},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1332
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   245,   256,    60,   151, 0x0,              STR_0190_SCROLL_BAR_SCROLLS_LIST},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1333
{      WWT_PANEL,    RESIZE_RTB,  COLOUR_GREY,     0,   256,   152,   167, 0x0,              STR_NULL},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1334
{    WWT_EDITBOX,    RESIZE_RTB,  COLOUR_GREY,     2,   254,   154,   165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1335
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,     0,   127,   168,   179, STR_4003_DELETE,  STR_400C_DELETE_THE_CURRENTLY_SELECTED},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1336
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,   128,   244,   168,   179, STR_4002_SAVE,    STR_400D_SAVE_THE_CURRENT_GAME_USING},
3598fc5cfdd5 (svn r13888) -Codechange: Replace numbers with Colours enum on miscellaneous guis.
belugas
parents: 9714
diff changeset
  1337
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   245,   256,   168,   179, 0x0,              STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
  1338
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1339
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1340
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6197
diff changeset
  1341
/* Colors for fios types */
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1342
const TextColour _fios_colors[] = {
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1343
	TC_LIGHT_BLUE, TC_DARK_GREEN,  TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1344
	TC_ORANGE,     TC_LIGHT_BROWN, TC_ORANGE,     TC_ORANGE, TC_YELLOW
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1345
};
2261
d3554e5d3e86 (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2255
diff changeset
  1346
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
  1347
void BuildFileList()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1348
{
1596
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1349
	_fios_path_changed = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1350
	FiosFreeSavegameList();
4223
d4c9ef555f43 (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4217
diff changeset
  1351
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1352
	switch (_saveload_mode) {
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1353
		case SLD_NEW_GAME:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1354
		case SLD_LOAD_SCENARIO:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1355
		case SLD_SAVE_SCENARIO:
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1356
			FiosGetScenarioList(_saveload_mode); break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1357
		case SLD_LOAD_HEIGHTMAP:
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1358
			FiosGetHeightmapList(_saveload_mode); break;
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1359
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1360
		default: FiosGetSavegameList(_saveload_mode); break;
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1361
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1362
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1363
2100
217ea6fdfd18 (svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents: 2070
diff changeset
  1364
static void DrawFiosTexts(uint maxw)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1365
{
1596
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1366
	static const char *path = NULL;
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1367
	static StringID str = STR_4006_UNABLE_TO_READ_DRIVE;
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1368
	static uint32 tot = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1369
1596
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1370
	if (_fios_path_changed) {
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1371
		str = FiosGetDescText(&path, &tot);
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1372
		_fios_path_changed = false;
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1373
	}
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1374
483007886b59 (svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents: 1594
diff changeset
  1375
	if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1376
	DrawString(2, 37, str, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7750
diff changeset
  1377
	DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1378
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1379
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
  1380
static void MakeSortedSaveGameList()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1381
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1382
	uint sort_start = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1383
	uint sort_end = 0;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1384
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1385
	/* Directories are always above the files (FIOS_TYPE_DIR)
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1386
	 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1387
	 * Only sort savegames/scenarios, not directories
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1388
	 */
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1389
	for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1390
		switch (item->type) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1391
			case FIOS_TYPE_DIR:    sort_start++; break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1392
			case FIOS_TYPE_PARENT: sort_start++; break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1393
			case FIOS_TYPE_DRIVE:  sort_end++;   break;
9031
445046ca06af (svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138
parents: 8973
diff changeset
  1394
			default: break;
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1395
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1396
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1397
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1398
	uint s_amount = _fios_items.Length() - sort_start - sort_end;
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1399
	if (s_amount > 0) {
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1400
		qsort(_fios_items.Get(sort_start), s_amount, sizeof(FiosItem), compare_FiosItems);
8819
e608a2ebe2b1 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 8809
diff changeset
  1401
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1402
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1403
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
  1404
extern void StartupEngines();
1131
305545b1f671 (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1405
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1406
struct SaveLoadWindow : public QueryStringBaseWindow {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1407
	FiosItem o_dir;
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3890
diff changeset
  1408
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1409
	void GenerateFileName()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1410
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1411
		/* Check if we are not a spectator who wants to generate a name..
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1412
		 * Let's use the name of player #0 for now. */
9652
0405e98d8e96 (svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents: 9648
diff changeset
  1413
		const Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
2100
217ea6fdfd18 (svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents: 2070
diff changeset
  1414
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1415
		SetDParam(0, p->index);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1416
		SetDParam(1, _date);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1417
		GetString(this->edit_str_buf, STR_4004, lastof(this->edit_str_buf));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1418
		SanitizeFilename(this->edit_str_buf);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1419
	}
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1420
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1421
	SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(desc)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1422
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1423
		static const StringID saveload_captions[] = {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1424
			STR_4001_LOAD_GAME,
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1425
			STR_0298_LOAD_SCENARIO,
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1426
			STR_4000_SAVE_GAME,
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1427
			STR_0299_SAVE_SCENARIO,
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1428
			STR_LOAD_HEIGHTMAP,
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1429
		};
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1430
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1431
		SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1432
		SetBit(_no_scroll, SCROLL_SAVE);
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1433
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1434
		/* Use an array to define what will be the current file type being handled
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1435
		 * by current file mode */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1436
		switch (mode) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1437
			case SLD_SAVE_GAME:     this->GenerateFileName(); break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1438
			case SLD_SAVE_SCENARIO: strcpy(this->edit_str_buf, "UNNAMED"); break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1439
			default:                break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1440
		}
2559
fe757666278c (svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents: 2549
diff changeset
  1441
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1442
		assert((uint)mode < lengthof(saveload_captions));
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1443
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1444
		this->widget[1].data = saveload_captions[mode];
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1445
		this->LowerWidget(7);
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1446
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1447
		this->afilter = CS_ALPHANUMERAL;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1448
		InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 240);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1449
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1450
		/* pause is only used in single-player, non-editor mode, non-menu mode. It
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1451
		 * will be unpaused in the WE_DESTROY event handler. */
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1452
		if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1453
			if (_pause_game >= 0) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1454
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1455
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1456
		BuildFileList();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1457
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1458
		ResetObjectToPlace();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1459
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1460
		o_dir.type = FIOS_TYPE_DIRECT;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1461
		switch (_saveload_mode) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1462
			case SLD_SAVE_GAME:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1463
			case SLD_LOAD_GAME:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1464
				FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1465
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1466
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1467
			case SLD_SAVE_SCENARIO:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1468
			case SLD_LOAD_SCENARIO:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1469
				FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1470
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1471
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1472
			case SLD_LOAD_HEIGHTMAP:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1473
				FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1474
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1475
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1476
			default:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1477
				ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1478
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1479
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1480
		this->vscroll.cap = 10;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1481
		this->resize.step_width = 2;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1482
		this->resize.step_height = 10;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1483
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1484
		this->FindWindowPlacementAndResize(desc);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1485
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1486
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1487
	virtual ~SaveLoadWindow()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1488
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1489
		/* pause is only used in single-player, non-editor mode, non menu mode */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1490
		if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1491
			if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1492
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1493
		FiosFreeSavegameList();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1494
		ClrBit(_no_scroll, SCROLL_SAVE);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1495
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1496
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1497
	virtual void OnPaint()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1498
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1499
		int y;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1500
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1501
		SetVScrollCount(this, _fios_items.Length());
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
  1502
		this->DrawWidgets();
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1503
		DrawFiosTexts(this->width);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1504
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1505
		if (_savegame_sort_dirty) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1506
			_savegame_sort_dirty = false;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1507
			MakeSortedSaveGameList();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1508
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1509
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1510
		GfxFillRect(this->widget[7].left + 1, this->widget[7].top + 1, this->widget[7].right, this->widget[7].bottom, 0xD7);
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9272
diff changeset
  1511
		this->DrawSortButtonState(_savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1512
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1513
		y = this->widget[7].top + 1;
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1514
		for (uint pos = this->vscroll.pos; pos < _fios_items.Length(); pos++) {
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1515
			const FiosItem *item = _fios_items.Get(pos);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1516
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1517
			DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], this->width - 18);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1518
			y += 10;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1519
			if (y >= this->vscroll.cap * 10 + this->widget[7].top + 1) break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1520
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1521
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1522
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1523
			this->DrawEditBox(10);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1524
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1525
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1526
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1527
	virtual void OnClick(Point pt, int widget)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1528
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1529
		switch (widget) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1530
			case 2: // Sort save names by name
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1531
				_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1532
					SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1533
				_savegame_sort_dirty = true;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1534
				this->SetDirty();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1535
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1536
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1537
			case 3: // Sort save names by date
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1538
				_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1539
					SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1540
				_savegame_sort_dirty = true;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1541
				this->SetDirty();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1542
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1543
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1544
			case 6: // OpenTTD 'button', jumps to OpenTTD directory
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1545
				FiosBrowseTo(&o_dir);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1546
				this->SetDirty();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1547
				BuildFileList();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1548
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1549
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1550
			case 7: { // Click the listbox
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1551
				int y = (pt.y - this->widget[widget].top - 1) / 10;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1552
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1553
				if (y < 0 || (y += this->vscroll.pos) >= this->vscroll.count) return;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1554
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1555
				const FiosItem *file = _fios_items.Get(y);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1556
9441
6f3d3595b42c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13
parents: 9413
diff changeset
  1557
				char *name = FiosBrowseTo(file);
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1558
				if (name != NULL) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1559
					if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1560
						_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1561
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1562
						SetFiosType(file->type);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1563
						ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1564
						ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1565
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1566
						delete this;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1567
					} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1568
						SetFiosType(file->type);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1569
						ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1570
						ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1571
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1572
						delete this;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1573
						ShowHeightmapLoad();
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1574
					} else {
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1575
						/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1576
						ttd_strlcpy(this->text.buf, file->title, this->text.maxlength);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1577
						UpdateTextBufferSize(&this->text);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1578
						this->InvalidateWidget(10);
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1579
					}
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1580
				} else {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1581
					/* Changed directory, need repaint. */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1582
					this->SetDirty();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1583
					BuildFileList();
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1584
				}
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1585
				break;
2255
fd5d5adee9d9 (svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents: 2201
diff changeset
  1586
			}
3288
5e0c047edca4 (svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents: 3287
diff changeset
  1587
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1588
			case 10: // edit box
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1589
				ShowOnScreenKeyboard(this, widget, 0, 0);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1590
				break;
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1591
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1592
			case 11: case 12: // Delete, Save game
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1593
				break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1594
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1595
	}
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1596
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1597
	virtual void OnMouseLoop()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1598
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1599
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1600
			this->HandleEditBox(10);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1601
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1602
	}
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1603
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1604
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1605
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1606
		if (keycode == WKC_ESC) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1607
			delete this;
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1608
			return ES_HANDLED;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1609
		}
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1610
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1611
		EventState state = ES_NOT_HANDLED;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1612
		if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1613
				this->HandleEditBoxKey(10, key, keycode, state) == 1) { // Press Enter
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1614
			this->HandleButtonClick(12);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1615
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1616
9285
235e5e2d7f55 (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
parents: 9273
diff changeset
  1617
		return state;
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1618
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1619
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1620
	virtual void OnTimeout()
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1621
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1622
		/* This test protects against using widgets 11 and 12 which are only available
9693
cbc09e498392 (svn r13800) -Codechange: minor comment style fixes in misc_gui.cpp
smatz
parents: 9682
diff changeset
  1623
		 * in those two saveload mode */
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1624
		if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) return;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1625
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1626
		if (this->IsWidgetLowered(11)) { // Delete button clicked
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1627
			if (!FiosDelete(this->text.buf)) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1628
				ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1629
			} else {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1630
				BuildFileList();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1631
				/* Reset file name to current date on successful delete */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1632
				if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
8738
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1633
			}
05aca6d9471b (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 8737
diff changeset
  1634
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1635
			UpdateTextBufferSize(&this->text);
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1636
			this->SetDirty();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1637
		} else if (this->IsWidgetLowered(12)) { // Save button clicked
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1638
			_switch_mode = SM_SAVE;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1639
			FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name));
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1640
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1641
			/* In the editor set up the vehicle engines correctly (date might have changed) */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1642
			if (_game_mode == GM_EDITOR) StartupEngines();
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1643
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1644
	}
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1645
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1646
	virtual void OnResize(Point new_size, Point delta)
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1647
	{
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1648
		/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1649
		uint diff = delta.x / 2;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1650
		this->widget[2].right += diff;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1651
		this->widget[3].left  += diff;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1652
		this->widget[3].right += delta.x;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1653
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1654
		/* Same for widget 11 and 12 in save-dialog */
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1655
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1656
			this->widget[11].right += diff;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1657
			this->widget[12].left  += diff;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1658
			this->widget[12].right += delta.x;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1659
		}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1660
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1661
		this->vscroll.cap += delta.y / 10;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1662
	}
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1663
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1664
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1665
static const WindowDesc _load_dialog_desc = {
7346
dcfda6aa096f (svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents: 7341
diff changeset
  1666
	WDP_CENTER, WDP_CENTER, 257, 154, 257, 294,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
  1667
	WC_SAVELOAD, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
  1668
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
5079
15816766b4ee (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1669
	_load_dialog_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1670
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1671
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1672
static const WindowDesc _save_dialog_desc = {
7346
dcfda6aa096f (svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents: 7341
diff changeset
  1673
	WDP_CENTER, WDP_CENTER, 257, 180, 257, 320,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5750
diff changeset
  1674
	WC_SAVELOAD, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
  1675
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1676
	_save_dialog_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1677
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1678
8152
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1679
/** These values are used to convert the file/operations mode into a corresponding file type.
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1680
 * So each entry, as expressed by the related comment, is based on the enum   */
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1681
static const FileType _file_modetotype[] = {
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1682
	FT_SAVEGAME,  ///< used for SLD_LOAD_GAME
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1683
	FT_SCENARIO,  ///< used for SLD_LOAD_SCENARIO
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1684
	FT_SAVEGAME,  ///< used for SLD_SAVE_GAME
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1685
	FT_SCENARIO,  ///< used for SLD_SAVE_SCENARIO
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1686
	FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1687
	FT_SAVEGAME,  ///< SLD_NEW_GAME
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1688
};
ab21de45f8ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8149
diff changeset
  1689
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8144
diff changeset
  1690
void ShowSaveLoadDialog(SaveLoadDialogMode mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1691
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1692
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1693
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1694
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1695
	const WindowDesc *sld;
1397
fa8539dcab46 (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents: 1392
diff changeset
  1696
	switch (mode) {
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1697
		case SLD_SAVE_GAME:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1698
		case SLD_SAVE_SCENARIO:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1699
			sld = &_save_dialog_desc; break;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1700
		default:
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1701
			sld = &_load_dialog_desc; break;
1397
fa8539dcab46 (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents: 1392
diff changeset
  1702
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1703
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1704
	_saveload_mode = mode;
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1705
	_file_to_saveload.filetype = _file_modetotype[mode];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1706
9179
780666b686ed (svn r13042) -Codechange: make a class of CreateScenarioWindow, GenerateLandscapeWindow, NetworkChatWindow, NetworkCompanyPasswordWindow, NetworkGameWindow, NetworkStartServerWindow, QueryStringWindow, SaveLoadWindow. All these classes depended on the 'querystr_d' object which is now put into QueryStringBaseWindow. As a side effect this removes quite a lot of WP macro usages and a few global variables.
rubidium
parents: 9178
diff changeset
  1707
	new SaveLoadWindow(sld, mode);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1708
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1709
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6239
diff changeset
  1710
void RedrawAutosave()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1711
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1712
	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1713
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1714
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1715
void SetFiosType(const byte fiostype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1716
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1717
	switch (fiostype) {
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1718
		case FIOS_TYPE_FILE:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1719
		case FIOS_TYPE_SCENARIO:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1720
			_file_to_saveload.mode = SL_LOAD;
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1721
			break;
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1722
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1723
		case FIOS_TYPE_OLDFILE:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1724
		case FIOS_TYPE_OLD_SCENARIO:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1725
			_file_to_saveload.mode = SL_OLD_LOAD;
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1726
			break;
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1727
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1728
#ifdef WITH_PNG
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1729
		case FIOS_TYPE_PNG:
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1730
			_file_to_saveload.mode = SL_PNG;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1731
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1732
#endif /* WITH_PNG */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1733
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1734
		case FIOS_TYPE_BMP:
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1735
			_file_to_saveload.mode = SL_BMP;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1736
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1737
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1738
		default:
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1739
			_file_to_saveload.mode = SL_INVALID;
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1740
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1741
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1742
}