src/misc_gui.cpp
author rubidium
Fri, 09 May 2008 09:29:27 +0000
changeset 10481 0c7aed4edabe
parent 10475 6b7ca9f978f0
child 10484 e8beb2845f13
permissions -rw-r--r--
(svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2167
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2167
diff changeset
     2
10429
1b99254f9607 (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: 10399
diff changeset
     3
/** @file misc_gui.cpp GUIs for a number of misc windows. */
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1879
diff changeset
     6
#include "openttd.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
     7
#include "heightmap.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1274
diff changeset
     8
#include "debug.h"
6949
72d11a1e1e60 (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: 6676
diff changeset
     9
#include "landscape.h"
5352
82a50c80b0c4 (svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents: 5320
diff changeset
    10
#include "newgrf.h"
8246
ff7b892d8a28 (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents: 8017
diff changeset
    11
#include "newgrf_text.h"
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 2159
diff changeset
    12
#include "saveload.h"
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8603
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"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    15
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    16
#include "station_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    17
#include "textbuf_gui.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    18
#include "viewport_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    19
#include "gfx_func.h"
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 9244
diff changeset
    20
#include "station_func.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    21
#include "command_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    22
#include "player_func.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
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"
5720
cc0ceeafaa55 (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: 5698
diff changeset
    25
#include "network/network.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2134
diff changeset
    26
#include "variables.h"
10225
8becb17444a7 (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 10155
diff changeset
    27
#include "cheat_func.h"
3890
f8f13a91446a (svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents: 3798
diff changeset
    28
#include "train.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    29
#include "tgp.h"
6417
26acff62d001 (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: 6144
diff changeset
    30
#include "cargotype.h"
6516
ee6d057b9850 (svn r8969) -Codechange: rework of the player face bits.
rubidium
parents: 6417
diff changeset
    31
#include "player_face.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8604
diff changeset
    32
#include "strings_func.h"
7425
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 7371
diff changeset
    33
#include "fileio.h"
4223
0f9535dda7ed (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"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8612
diff changeset
    35
#include "tile_cmd.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8617
diff changeset
    36
#include "zoom_func.h"
8627
448ebf3a8291 (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: 8619
diff changeset
    37
#include "functions.h"
448ebf3a8291 (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: 8619
diff changeset
    38
#include "window_func.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8635
diff changeset
    39
#include "date_func.h"
8653
a83f7a536919 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8648
diff changeset
    40
#include "sound_func.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8704
diff changeset
    41
#include "string_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    42
#include "player_gui.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    43
#include "settings_type.h"
9283
624272490f5a (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 9281
diff changeset
    44
#include "newgrf_cargo.h"
9305
0c214cd8b39e (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 9283
diff changeset
    45
#include "rail_gui.h"
10445
2dd7d9d0a957 (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 10434
diff changeset
    46
#include "tilehighlight_func.h"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8612
diff changeset
    47
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    48
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    49
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    50
4223
0f9535dda7ed (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
    51
/* Variables to display file lists */
0f9535dda7ed (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
    52
FiosItem *_fios_list;
8645
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8640
diff changeset
    53
SaveLoadDialogMode _saveload_mode;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    55
1596
c1c439a2d5b2 (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
    56
static bool _fios_path_changed;
1594
1cbbb77f5bb2 (svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents: 1578
diff changeset
    57
static bool _savegame_sort_dirty;
1cbbb77f5bb2 (svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents: 1578
diff changeset
    58
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
static const Widget _land_info_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    60
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
    61
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   279,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
    62
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,    14,    92, 0x0,                            STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
    63
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
};
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
static const WindowDesc _land_info_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
    67
	WDP_AUTO, WDP_AUTO, 280, 93, 280, 93,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
    68
	WC_LAND_INFO, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	_land_info_widgets,
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    71
	NULL
0
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
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    74
class LandInfoWindow : public Window {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    75
	enum {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    76
		LAND_INFO_LINES          =   7,
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    77
		LAND_INFO_LINE_BUFF_SIZE = 512,
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    78
	};
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
    79
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    80
public:
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    81
	char landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE];
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
    82
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    83
	virtual void HandleWindowEvent(WindowEvent *e)
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    84
	{
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    85
		if (e->event != WE_PAINT) return;
5834
7bf92d5a5a0f (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: 5726
diff changeset
    86
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    87
		DrawWindowWidgets(this);
5834
7bf92d5a5a0f (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: 5726
diff changeset
    88
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    89
		DoDrawStringCentered(140, 16, this->landinfo_data[0], TC_LIGHT_BLUE);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    90
		DoDrawStringCentered(140, 27, this->landinfo_data[1], TC_FROMSTRING);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    91
		DoDrawStringCentered(140, 38, this->landinfo_data[2], TC_FROMSTRING);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    92
		DoDrawStringCentered(140, 49, this->landinfo_data[3], TC_FROMSTRING);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    93
		DoDrawStringCentered(140, 60, this->landinfo_data[4], TC_FROMSTRING);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    94
		if (!StrEmpty(this->landinfo_data[5])) DrawStringMultiCenter(140, 76, BindCString(this->landinfo_data[5]), this->width - 4);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    95
		if (!StrEmpty(this->landinfo_data[6])) DoDrawStringCentered(140, 71, this->landinfo_data[6], TC_FROMSTRING);
5834
7bf92d5a5a0f (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: 5726
diff changeset
    96
	}
7bf92d5a5a0f (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: 5726
diff changeset
    97
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    98
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
    99
		Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   100
		Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
5834
7bf92d5a5a0f (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: 5726
diff changeset
   101
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   102
		Money old_money = p->player_money;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   103
		p->player_money = INT64_MAX;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   104
		CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   105
		p->player_money = old_money;
5834
7bf92d5a5a0f (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: 5726
diff changeset
   106
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   107
		/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   108
		TileDesc td;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   109
		AcceptedCargo ac;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   110
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   111
		td.build_date = 0;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   112
		GetAcceptedCargo(tile, ac);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   113
		GetTileDesc(tile, &td);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   114
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   115
		SetDParam(0, td.dparam[0]);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   116
		GetString(this->landinfo_data[0], td.str, lastof(this->landinfo_data[0]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   117
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   118
		SetDParam(0, STR_01A6_N_A);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   119
		if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   120
		GetString(this->landinfo_data[1], STR_01A7_OWNER, lastof(this->landinfo_data[1]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   121
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   122
		StringID str = STR_01A4_COST_TO_CLEAR_N_A;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   123
		if (CmdSucceeded(costclear)) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   124
			SetDParam(0, costclear.GetCost());
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   125
			str = STR_01A5_COST_TO_CLEAR;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   126
		}
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   127
		GetString(this->landinfo_data[2], str, lastof(this->landinfo_data[2]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   128
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   129
		snprintf(_userstring, lengthof(_userstring), "0x%.4X", tile);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   130
		SetDParam(0, TileX(tile));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   131
		SetDParam(1, TileY(tile));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   132
		SetDParam(2, TileHeight(tile));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   133
		SetDParam(3, STR_SPEC_USERSTRING);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   134
		GetString(this->landinfo_data[3], STR_LANDINFO_COORDS, lastof(this->landinfo_data[3]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   135
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   136
		SetDParam(0, STR_01A9_NONE);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   137
		if (t != NULL && t->IsValid()) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   138
			SetDParam(0, STR_TOWN);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   139
			SetDParam(1, t->index);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   140
		}
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   141
		GetString(this->landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[4]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   142
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   143
		char *strp = GetString(this->landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[5]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   144
		bool found = false;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   145
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   146
		for (CargoID i = 0; i < NUM_CARGO; ++i) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   147
			if (ac[i] > 0) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   148
				/* Add a comma between each item. */
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   149
				if (found) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   150
					*strp++ = ',';
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   151
					*strp++ = ' ';
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   152
				}
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   153
				found = true;
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   154
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   155
				/* If the accepted value is less than 8, show it in 1/8:ths */
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   156
				if (ac[i] < 8) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   157
					SetDParam(0, ac[i]);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   158
					SetDParam(1, GetCargo(i)->name);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   159
					strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[5]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   160
				} else {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   161
					strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[5]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   162
				}
5834
7bf92d5a5a0f (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: 5726
diff changeset
   163
			}
7bf92d5a5a0f (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: 5726
diff changeset
   164
		}
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   165
		if (!found) this->landinfo_data[5][0] = '\0';
5834
7bf92d5a5a0f (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: 5726
diff changeset
   166
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   167
		if (td.build_date != 0) {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   168
			SetDParam(0, td.build_date);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   169
			GetString(this->landinfo_data[6], STR_BUILD_DATE, lastof(this->landinfo_data[6]));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   170
		} else {
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   171
			this->landinfo_data[6][0] = '\0';
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   172
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   173
4000
bab1ebc37da0 (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
   174
#if defined(_DEBUG)
bab1ebc37da0 (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
   175
#	define LANDINFOD_LEVEL 0
bab1ebc37da0 (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
   176
#else
bab1ebc37da0 (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
   177
#	define LANDINFOD_LEVEL 1
bab1ebc37da0 (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
   178
#endif
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   179
		DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   180
		DEBUG(misc, LANDINFOD_LEVEL, "type_height  = %#x", _m[tile].type_height);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   181
		DEBUG(misc, LANDINFOD_LEVEL, "m1           = %#x", _m[tile].m1);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   182
		DEBUG(misc, LANDINFOD_LEVEL, "m2           = %#x", _m[tile].m2);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   183
		DEBUG(misc, LANDINFOD_LEVEL, "m3           = %#x", _m[tile].m3);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   184
		DEBUG(misc, LANDINFOD_LEVEL, "m4           = %#x", _m[tile].m4);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   185
		DEBUG(misc, LANDINFOD_LEVEL, "m5           = %#x", _m[tile].m5);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   186
		DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   187
		DEBUG(misc, LANDINFOD_LEVEL, "m7           = %#x", _me[tile].m7);
4000
bab1ebc37da0 (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
   188
#undef LANDINFOD_LEVEL
10475
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   189
	}
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   190
};
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   191
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   192
static void Place_LandInfo(TileIndex tile)
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   193
{
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   194
	DeleteWindowById(WC_LAND_INFO, 0);
6b7ca9f978f0 (svn r13018) -Codechange: make a class of the LandInfo Window.
rubidium
parents: 10472
diff changeset
   195
	new LandInfoWindow(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
   198
void PlaceLandBlockInfo()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   200
	if (_cursor.sprite == SPR_CURSOR_QUERY) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
		_place_proc = Place_LandInfo;
8385
aedd7656cfd1 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 8355
diff changeset
   204
		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
   205
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
10472
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   208
struct scroller_d {
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   209
	int height;
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   210
	uint16 counter;
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   211
};
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   212
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   213
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   214
static const char *credits[] = {
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   215
	/*************************************************************************
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   216
	 *                      maximum length of string which fits in window   -^*/
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   217
	"Original design by Chris Sawyer",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   218
	"Original graphics by Simon Foster",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   219
	"",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   220
	"The OpenTTD team (in alphabetical order):",
8555
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   221
	"  Jean-Francois Claeys (Belugas) - GUI, newindustries and more",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   222
	"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   223
	"  Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   224
	"  Loïc Guilloux (glx) - General coding",
9119
d2b7d20a8ab1 (svn r12206) -Fix: A comma is not a rare resource. Do not hesitate to use it when needed.
belugas
parents: 9101
diff changeset
   225
	"  Christoph Elsenhans (frosch) - General coding",
5355
cd06af29b842 (svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents: 5352
diff changeset
   226
	"  Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
6565
3cea8776104b (svn r9042) -Add : Maedhros as a developper
belugas
parents: 6540
diff changeset
   227
	"  Jonathan Coome (Maedhros) - High priest of the newGRF Temple",
5108
dc67d70b5a45 (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
   228
	"  Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
7570
4a7a62ec3e3e (svn r10339) -Fix r10311: if you fix your own name, at least also update your description ;)
truelight
parents: 7554
diff changeset
   229
	"  Owen Rudge (orudge) - Forum host, OS/2 port",
8680
d9f919f13088 (svn r11747) -Change: Return of the prodigal son (or something). Little update (but highly noticed) on the OpenTTD Team
belugas
parents: 8653
diff changeset
   230
	"  Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
8555
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   231
	"  Remko Bijker (Rubidium) - Lead coder and way more",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   232
	"  Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   233
	"  Zdenek Sojka (SmatZ) - Bug finder and fixer",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   234
	"",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   235
	"Inactive Developers:",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   236
	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   237
	"  Tamás Faragó (Darkvater) - Ex-Lead coder",
1126
5d778d55d094 (svn r1627) -Fix: The tabulizer in action ^_^
darkvater
parents: 1125
diff changeset
   238
	"  Christoph Mallon (Tron) - Programmer, code correctness police",
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   239
	"",
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   240
	"Retired Developers:",
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   241
	"  Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   242
	"  Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)",
1826
d123cb6b11dc (svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents: 1821
diff changeset
   243
	"  Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
8355
d2fd84767817 (svn r11409) -Update: as of now, I am a retired Developer, so mark me as such
truelight
parents: 8320
diff changeset
   244
	"  Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   245
	"",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   246
	"Special thanks go out to:",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   247
	"  Josef Drexler - For his great work on TTDPatch",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   248
	"  Marcin Grzegorczyk - For his documentation of TTD internals",
8555
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   249
	"  Petr Baudis (pasky) - Many patches, newGRF support",
5108
dc67d70b5a45 (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
   250
	"  Stefan Meißner (sign_de) - For his work on the console",
8555
4f5730a15567 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents: 8549
diff changeset
   251
	"  Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   252
	"  Cian Duffy (MYOB) - BeOS port / manual writing",
4133
88f290592081 (svn r5489) -Fix: corrected tokai's name and morphos details (tokai)
truelight
parents: 4091
diff changeset
   253
	"  Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
5355
cd06af29b842 (svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents: 5352
diff changeset
   254
	"  Richard Kempton (richK) - additional airports, initial TGP implementation",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   255
	"",
5108
dc67d70b5a45 (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
   256
	"  Michael Blunck - Pre-Signals and Semaphores © 2003",
dc67d70b5a45 (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
   257
	"  George - Canal/Lock graphics © 2003-2004",
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7166
diff changeset
   258
	"  David Dallaston - Tram tracks",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   259
	"  Marcin Grzegorczyk - Foundations for Tracks on Slopes",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   260
	"  All Translators - Who made OpenTTD a truly international game",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   261
	"  Bug Reporters - Without whom OpenTTD would still be full of bugs!",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   262
	"",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   263
	"",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   264
	"And last but not least:",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   265
	"  Chris Sawyer - For an amazing game!"
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   266
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
static void AboutWindowProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   270
	switch (e->event) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   271
		case WE_CREATE: // Set up window counter and start position of scroller
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   272
			WP(w, scroller_d).counter = 5;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   273
			WP(w, scroller_d).height = w->height - 40;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   274
			break;
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   275
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   276
		case WE_PAINT: {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   277
			int y = WP(w, scroller_d).height;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   278
			DrawWindowWidgets(w);
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   279
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   280
			/* Show original copyright and revision version */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   281
			DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   282
			DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING);
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   283
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   284
			/* Show all scrolling credits */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   285
			for (uint i = 0; i < lengthof(credits); i++) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   286
				if (y >= 50 && y < (w->height - 40)) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   287
					DoDrawString(credits[i], 10, y, TC_BLACK);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   288
				}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   289
				y += 10;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   290
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   291
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   292
			/* If the last text has scrolled start anew from the start */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   293
			if (y < 50) WP(w, scroller_d).height = w->height - 40;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   294
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   295
			DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   296
			DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   297
		} break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   298
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   299
		case WE_TICK: // Timer to scroll the text and adjust the new top
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   300
			if (--WP(w, scroller_d).counter == 0) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   301
				WP(w, scroller_d).counter = 5;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   302
				WP(w, scroller_d).height--;
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
   303
				w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   304
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   305
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
static const Widget _about_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   310
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   311
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   419,     0,    13, STR_015B_OPENTTD, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   312
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   419,    14,   271, 0x0,              STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   313
{      WWT_FRAME,   RESIZE_NONE,    14,     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
   314
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
static const WindowDesc _about_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
   318
	WDP_CENTER, WDP_CENTER, 420, 272, 420, 272,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
   319
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	_about_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	AboutWindowProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
   326
void ShowAboutWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
	DeleteWindowById(WC_GAME_OPTIONS, 0);
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
   329
	new Window(&_about_desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
7498
ce6588257e8d (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: 7494
diff changeset
   332
static uint64 _errmsg_decode_params[20];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
static StringID _errmsg_message_1, _errmsg_message_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
static uint _errmsg_duration;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
static const Widget _errmsg_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   338
{   WWT_CLOSEBOX,   RESIZE_NONE,     4,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   339
{    WWT_CAPTION,   RESIZE_NONE,     4,    11,   239,     0,    13, STR_00B2_MESSAGE, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   340
{      WWT_PANEL,   RESIZE_NONE,     4,     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
   341
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
static const Widget _errmsg_face_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   345
{   WWT_CLOSEBOX,   RESIZE_NONE,     4,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   346
{    WWT_CAPTION,   RESIZE_NONE,     4,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   347
{      WWT_PANEL,   RESIZE_NONE,     4,     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
   348
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
static void ErrmsgWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   353
	switch (e->event) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   354
		case WE_PAINT:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   355
			CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   356
			DrawWindowWidgets(w);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   357
			CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params));
8246
ff7b892d8a28 (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents: 8017
diff changeset
   358
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   359
			/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages.
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   360
			* 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
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   361
			*/
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   362
			SwitchToErrorRefStack();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   363
			RewindTextRefStack();
8246
ff7b892d8a28 (svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents: 8017
diff changeset
   364
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   365
			if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
				DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
					120,
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   368
					(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15),
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   369
					_errmsg_message_2,
6523
d41352ca5c1e (svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents: 6516
diff changeset
   370
					w->width - 2);
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   371
				if (_errmsg_message_1 != INVALID_STRING_ID) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   372
					DrawStringMultiCenter(
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   373
						120,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   374
						30,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   375
						_errmsg_message_1,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   376
						w->width - 2);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   377
				}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   378
			} else {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   379
				const Player *p = GetPlayer((PlayerID)GetDParamX(_errmsg_decode_params,2));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   380
				DrawPlayerFace(p->face, p->player_color, 2, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
				DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
					214,
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   384
					(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   385
					_errmsg_message_2,
6523
d41352ca5c1e (svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents: 6516
diff changeset
   386
					w->width - 2);
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   387
				if (_errmsg_message_1 != INVALID_STRING_ID) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   388
					DrawStringMultiCenter(
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   389
						214,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   390
						90,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   391
						_errmsg_message_1,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   392
						w->width - 2);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   393
				}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   394
			}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   395
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   396
			/* Switch back to the normal text ref. stack for NewGRF texts */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   397
			SwitchToNormalRefStack();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   398
			break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   399
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   400
		case WE_MOUSELOOP:
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
   401
			if (_right_button_down) delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   402
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
10481
0c7aed4edabe (svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
rubidium
parents: 10475
diff changeset
   404
		case WE_100_TICKS:
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
   405
			if (--_errmsg_duration == 0) delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   406
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   407
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   408
		case WE_DESTROY:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   409
			SetRedErrorSquare(0);
10233
c08376c16fb2 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium
parents: 10229
diff changeset
   410
			extern StringID _switch_mode_errorstr;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   411
			_switch_mode_errorstr = INVALID_STRING_ID;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   412
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   413
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   414
		case WE_KEYPRESS:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   415
			if (e->we.keypress.keycode == WKC_SPACE) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   416
				/* Don't continue. */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   417
				e->we.keypress.cont = false;
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
   418
				delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   419
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   420
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
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
   425
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
	DeleteWindowById(WC_ERRMSG, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   428
	if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
	_errmsg_message_1 = msg_1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
	_errmsg_message_2 = msg_2;
7762
03721db0ac1c (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7737
diff changeset
   432
	CopyOutDParam(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	_errmsg_duration = _patches.errmsg_duration;
5120
e12dfc67761f (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5116
diff changeset
   434
	if (!_errmsg_duration) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   435
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   436
	Point pt;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   437
	const ViewPort *vp;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   438
	Window *w;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   439
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   440
	if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   441
		if ((x | y) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
			pt = RemapCoords2(x, y);
5120
e12dfc67761f (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5116
diff changeset
   443
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
   445
			/* move x pos to opposite corner */
7122
0607a15aedc0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6988
diff changeset
   446
			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
   447
			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
   448
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
   449
			/* move y pos to opposite corner */
7122
0607a15aedc0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6988
diff changeset
   450
			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
   451
			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
   452
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
			pt.x = (_screen.width - 240) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
			pt.y = (_screen.height - 46) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
		}
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
   457
		w = new Window(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
	} else {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   459
		if ((x | y) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
			pt = RemapCoords2(x, y);
5120
e12dfc67761f (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5116
diff changeset
   461
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   462
			pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   463
			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
   464
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
			pt.x = (_screen.width - 334) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
			pt.y = (_screen.height - 137) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
		}
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
   468
		w = new Window(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
	w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
7486
d130c10f4dab (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 7449
diff changeset
   475
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
{
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2475
diff changeset
   477
	StringID msg = STR_0805_ESTIMATED_COST;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
		msg = STR_0807_ESTIMATED_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
	}
7498
ce6588257e8d (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: 7494
diff changeset
   483
	SetDParam(0, cost);
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2475
diff changeset
   484
	ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
7486
d130c10f4dab (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 7449
diff changeset
   487
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
   488
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
	Point pt = RemapCoords(x,y,z);
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   490
	StringID msg = STR_0801_COST;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
		msg = STR_0803_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
	}
7498
ce6588257e8d (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: 7494
diff changeset
   496
	SetDParam(0, cost);
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   497
	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
   498
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
7486
d130c10f4dab (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 7449
diff changeset
   500
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   501
{
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   502
	Point pt = RemapCoords(x,y,z);
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   503
7498
ce6588257e8d (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: 7494
diff changeset
   504
	SetDParam(0, cost);
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   505
	AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   506
}
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   507
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   508
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   509
{
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   510
	Point pt = RemapCoords(x, y, z);
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   511
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   512
	assert(string != STR_NULL);
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   513
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   514
	SetDParam(0, percent);
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   515
	return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   516
}
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   517
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   518
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   519
{
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   520
	assert(string != STR_NULL);
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   521
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   522
	SetDParam(0, percent);
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7503
diff changeset
   523
	UpdateTextEffect(te_id, string);
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   524
}
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   525
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   526
void HideFillingPercent(TextEffectID te_id)
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   527
{
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7487
diff changeset
   528
	if (te_id != INVALID_TE_ID) RemoveTextEffect(te_id);
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   529
}
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   530
10472
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   531
struct tooltips_d {
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   532
	StringID string_id;
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   533
	byte paramcount;
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   534
	uint64 params[5];
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   535
};
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   536
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
a9e62fc5400f (svn r13015) -Codechange: move some 'WP' structs out of window_gui.h to the .cpp files where they are actually used.
rubidium
parents: 10467
diff changeset
   537
2275
cbaeb07740b1 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   538
static const Widget _tooltips_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   539
{      WWT_PANEL,   RESIZE_NONE,    14,     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
   540
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
static void TooltipsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   546
	switch (e->event) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   547
		case WE_PAINT:
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   548
			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   549
			GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44);
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   550
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   551
			for (uint arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) {
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   552
				SetDParam(arg, WP(w, tooltips_d).params[arg]);
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   553
			}
6523
d41352ca5c1e (svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents: 6516
diff changeset
   554
			DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w, tooltips_d).string_id, w->width - 2);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   555
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   557
		case WE_MOUSELOOP:
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   558
			/* We can show tooltips while dragging tools. These are shown as long as
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   559
			 * we are dragging the tool. Normal tooltips work with rmb */
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   560
			if (WP(w, tooltips_d).paramcount == 0 ) {
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
   561
				if (!_right_button_down) delete w;
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   562
			} else {
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
   563
				if (!_left_button_down) delete w;
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   564
			}
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   565
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   566
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   570
/** Shows a tooltip
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   571
 * @param str String to be displayed
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   572
 * @param paramcount number of params to deal with
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   573
 * @param params (optional) up to 5 pieces of additional information that may be
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   574
 * added to a tooltip; currently only supports parameters of {NUM} (integer) */
7502
71f5d2c6a605 (svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents: 7498
diff changeset
   575
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[])
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
{
4884
895f06b87934 (svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents: 4850
diff changeset
   577
	DeleteWindowById(WC_TOOLTIPS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
4884
895f06b87934 (svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents: 4850
diff changeset
   579
	/* We only show measurement tooltips with patch setting on */
895f06b87934 (svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents: 4850
diff changeset
   580
	if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   582
	for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   583
	char buffer[512];
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4909
diff changeset
   584
	GetString(buffer, str, lastof(buffer));
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   585
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   586
	Dimension br = GetStringBoundingBox(buffer);
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   587
	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
   588
4558
657e73957b4b (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   589
	/* Cut tooltip length to 200 pixels max, wrap to new line if longer */
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   590
	if (br.width > 200) {
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   591
		br.height += ((br.width - 4) / 176) * 10;
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   592
		br.width = 200;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
4558
657e73957b4b (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   595
	/* Correctly position the tooltip position, watch out for window and cursor size
657e73957b4b (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   596
	 * Clamp value to below main toolbar and above statusbar. If tooltip would
657e73957b4b (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   597
	 * go below window, flip it so it is shown above the cursor */
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   598
	int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   599
	if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   600
	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
   601
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
   602
	Window *w = new Window(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   603
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   604
	WP(w, tooltips_d).string_id = str;
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   605
	assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0]));
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   606
	memcpy(WP(w, tooltips_d).params, params, sizeof(WP(w, tooltips_d).params[0]) * paramcount);
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   607
	WP(w, tooltips_d).paramcount = paramcount;
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   608
4558
657e73957b4b (svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents: 4416
diff changeset
   609
	w->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   610
	w->widget[0].right = br.width;
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4719
diff changeset
   611
	w->widget[0].bottom = br.height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
9342
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   615
static int DrawStationCoverageText(const AcceptedCargo cargo,
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   616
	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
   617
{
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   618
	bool first = true;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   619
9342
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   620
	char *b = InlineString(_userstring, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
7737
7ab95e599292 (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: 7634
diff changeset
   622
	for (CargoID i = 0; i < NUM_CARGO; i++) {
8537
0b4ab7d8b018 (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8532
diff changeset
   623
		if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
7737
7ab95e599292 (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: 7634
diff changeset
   624
		switch (sct) {
7ab95e599292 (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: 7634
diff changeset
   625
			case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
7ab95e599292 (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: 7634
diff changeset
   626
			case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
7ab95e599292 (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: 7634
diff changeset
   627
			case SCT_ALL: break;
7ab95e599292 (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: 7634
diff changeset
   628
			default: NOT_REACHED();
7ab95e599292 (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: 7634
diff changeset
   629
		}
10155
84b04fa63a70 (svn r12686) -Fix: MSVC signed/unsigned warning
glx
parents: 9342
diff changeset
   630
		if (cargo[i] >= (supplies ? 1U : 8U)) {
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   631
			if (first) {
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   632
				first = false;
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   633
			} else {
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   634
				/* Add a comma if this is not the first item */
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   635
				*b++ = ',';
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   636
				*b++ = ' ';
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   637
			}
6417
26acff62d001 (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: 6144
diff changeset
   638
			b = InlineString(b, GetCargo(i)->name);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   642
	/* If first is still true then no cargo is accepted */
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   643
	if (first) b = InlineString(b, STR_00D0_NOTHING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
5038
cd0a32afb616 (svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents: 5005
diff changeset
   645
	*b = '\0';
8537
0b4ab7d8b018 (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8532
diff changeset
   646
0b4ab7d8b018 (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8532
diff changeset
   647
	/* Make sure we detect any buffer overflow */
0b4ab7d8b018 (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8532
diff changeset
   648
	assert(b < endof(_userstring));
0b4ab7d8b018 (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents: 8532
diff changeset
   649
8919
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8845
diff changeset
   650
	return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
9342
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   653
/**
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   654
 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   655
 * @param sx x position where the string is to be drawn
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   656
 * @param sy y position where the string is to be drawn
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   657
 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   658
 * @param rad radius around selected tile(s) to be searched
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   659
 * @param supplies if supplied cargos should be drawn, else accepted cargos
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   660
 * @return Returns the y value below the string that was drawn
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   661
 */
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   662
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
7817
f24498d934ac (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7762
diff changeset
   663
{
2873
75b688d160d5 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   664
	TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
9342
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   665
	AcceptedCargo cargo;
2873
75b688d160d5 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   666
	if (tile < MapSize()) {
9342
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   667
		if (supplies) {
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   668
			GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   669
		} else {
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   670
			GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   671
		}
ca61cbfca47a (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 9327
diff changeset
   672
		return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
	}
8919
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8845
diff changeset
   674
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8845
diff changeset
   675
	return sy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
   678
void CheckRedrawStationCoverage(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   680
	if (_thd.dirty & 1) {
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   681
		_thd.dirty &= ~1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
void SetVScrollCount(Window *w, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
	w->vscroll.count = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
	num -= w->vscroll.cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
	if (num < 0) num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
	if (num < w->vscroll.pos) w->vscroll.pos = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   694
void SetVScroll2Count(Window *w, int num)
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   695
{
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   696
	w->vscroll2.count = num;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   697
	num -= w->vscroll2.cap;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   698
	if (num < 0) num = 0;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   699
	if (num < w->vscroll2.pos) w->vscroll2.pos = num;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   700
}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   701
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
void SetHScrollCount(Window *w, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
	w->hscroll.count = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	num -= w->hscroll.cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
	if (num < 0) num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
	if (num < w->hscroll.pos) w->hscroll.pos = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
5108
dc67d70b5a45 (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
   710
/* Delete a character at the caret position in a text buf.
dc67d70b5a45 (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
   711
 * If backspace is set, delete the character before the caret,
dc67d70b5a45 (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
   712
 * else delete the character after it. */
dc67d70b5a45 (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
   713
static void DelChar(Textbuf *tb, bool backspace)
911
bde79514283f (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
   714
{
5108
dc67d70b5a45 (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
   715
	WChar c;
6540
4db000b2cc41 (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: 6537
diff changeset
   716
	char *s = tb->buf + tb->caretpos;
5108
dc67d70b5a45 (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
   717
6540
4db000b2cc41 (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: 6537
diff changeset
   718
	if (backspace) s = Utf8PrevChar(s);
5108
dc67d70b5a45 (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
   719
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   720
	size_t len = Utf8Decode(&c, s);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   721
	uint width = GetCharacterWidth(FS_NORMAL, c);
5108
dc67d70b5a45 (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
   722
dc67d70b5a45 (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
   723
	tb->width  -= width;
6540
4db000b2cc41 (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: 6537
diff changeset
   724
	if (backspace) {
4db000b2cc41 (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: 6537
diff changeset
   725
		tb->caretpos   -= len;
4db000b2cc41 (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: 6537
diff changeset
   726
		tb->caretxoffs -= width;
4db000b2cc41 (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: 6537
diff changeset
   727
	}
5108
dc67d70b5a45 (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
   728
dc67d70b5a45 (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
   729
	/* Move the remaining characters over the marker */
6540
4db000b2cc41 (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: 6537
diff changeset
   730
	memmove(s, s + len, tb->length - (s - tb->buf) - len + 1);
5108
dc67d70b5a45 (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
   731
	tb->length -= len;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   732
}
911
bde79514283f (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
   733
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   734
/**
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   735
 * Delete a character from a textbuffer, either with 'Delete' or 'Backspace'
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   736
 * The character is delete from the position the caret is at
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   737
 * @param tb Textbuf type to be changed
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   738
 * @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
7868
25b9aad39e4a (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7842
diff changeset
   739
 * @return Return true on successful change of Textbuf, or false otherwise
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   740
 */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   741
bool DeleteTextBufferChar(Textbuf *tb, int delmode)
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   742
{
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   743
	if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
5108
dc67d70b5a45 (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
   744
		DelChar(tb, true);
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   745
		return true;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   746
	} else if (delmode == WKC_DELETE && tb->caretpos < tb->length) {
5108
dc67d70b5a45 (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
   747
		DelChar(tb, false);
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   748
		return true;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   749
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   750
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   751
	return false;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   752
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   753
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   754
/**
1879
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   755
 * Delete every character in the textbuffer
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   756
 * @param tb Textbuf buffer to be emptied
1879
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   757
 */
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   758
void DeleteTextBufferAll(Textbuf *tb)
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   759
{
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   760
	memset(tb->buf, 0, tb->maxlength);
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   761
	tb->length = tb->width = 0;
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   762
	tb->caretpos = tb->caretxoffs = 0;
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   763
}
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   764
2ccc61e922e2 (svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents: 1860
diff changeset
   765
/**
3459
b78229520bcf (svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents: 3458
diff changeset
   766
 * Insert a character to a textbuffer. If maxwidth of the Textbuf is zero,
b78229520bcf (svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents: 3458
diff changeset
   767
 * we don't care about the visual-length but only about the physical
3458
d3a6ddfa6784 (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
   768
 * length of the string
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   769
 * @param tb Textbuf type to be changed
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   770
 * @param key Character to be inserted
7868
25b9aad39e4a (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7842
diff changeset
   771
 * @return Return true on successful change of Textbuf, or false otherwise
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   772
 */
5108
dc67d70b5a45 (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
bool InsertTextBufferChar(Textbuf *tb, WChar key)
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   774
{
3798
37a2090eac94 (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
   775
	const byte charwidth = GetCharacterWidth(FS_NORMAL, key);
5108
dc67d70b5a45 (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
   776
	size_t len = Utf8CharLen(key);
dc67d70b5a45 (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
	if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) {
dc67d70b5a45 (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
   778
		memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1);
dc67d70b5a45 (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
		Utf8Encode(tb->buf + tb->caretpos, key);
dc67d70b5a45 (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
   780
		tb->length += len;
dc67d70b5a45 (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
		tb->width  += charwidth;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   782
5108
dc67d70b5a45 (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
   783
		tb->caretpos   += len;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   784
		tb->caretxoffs += charwidth;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   785
		return true;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   786
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   787
	return false;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   788
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   789
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   790
/**
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   791
 * Handle text navigation with arrow keys left/right.
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   792
 * This defines where the caret will blink and the next characer interaction will occur
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   793
 * @param tb Textbuf type where navigation occurs
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   794
 * @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
7868
25b9aad39e4a (svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents: 7842
diff changeset
   795
 * @return Return true on successful change of Textbuf, or false otherwise
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   796
 */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   797
bool MoveTextBufferPos(Textbuf *tb, int navmode)
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   798
{
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   799
	switch (navmode) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   800
		case WKC_LEFT:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   801
			if (tb->caretpos != 0) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   802
				WChar c;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   803
				const char *s = Utf8PrevChar(tb->buf + tb->caretpos);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   804
				Utf8Decode(&c, s);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   805
				tb->caretpos    = s - tb->buf; // -= (tb->buf + tb->caretpos - s)
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   806
				tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c);
5108
dc67d70b5a45 (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
   807
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   808
				return true;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   809
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   810
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   811
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   812
		case WKC_RIGHT:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   813
			if (tb->caretpos < tb->length) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   814
				WChar c;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   815
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   816
				tb->caretpos   += Utf8Decode(&c, tb->buf + tb->caretpos);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   817
				tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   818
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   819
				return true;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   820
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   821
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   822
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   823
		case WKC_HOME:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   824
			tb->caretpos = 0;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   825
			tb->caretxoffs = 0;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   826
			return true;
5108
dc67d70b5a45 (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
   827
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   828
		case WKC_END:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   829
			tb->caretpos = tb->length;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   830
			tb->caretxoffs = tb->width;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   831
			return true;
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   832
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   833
		default:
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   834
			break;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   835
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   836
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   837
	return false;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   838
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   839
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   840
/**
4948
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   841
 * Initialize the textbuffer by supplying it the buffer to write into
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   842
 * and the maximum length of this buffer
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   843
 * @param tb Textbuf type which is getting initialized
4948
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   844
 * @param buf the buffer that will be holding the data for input
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   845
 * @param maxlength maximum length in characters of this buffer
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   846
 * @param maxwidth maximum length in pixels of this buffer. If reached, buffer
4958
aaa8a92059bf (svn r6957) -Cleanup: comments, coding style
Darkvater
parents: 4955
diff changeset
   847
 * cannot grow, even if maxlength would allow because there is space. A length
aaa8a92059bf (svn r6957) -Cleanup: comments, coding style
Darkvater
parents: 4955
diff changeset
   848
 * of zero '0' means the buffer is only restricted by maxlength */
4948
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   849
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth)
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   850
{
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   851
	tb->buf = (char*)buf;
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   852
	tb->maxlength = maxlength;
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   853
	tb->maxwidth  = maxwidth;
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   854
	tb->caret = true;
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   855
	UpdateTextBufferSize(tb);
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   856
}
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   857
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
   858
/**
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   859
 * Update Textbuf type with its actual physical character and screenlength
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   860
 * Get the count of characters in the string as well as the width in pixels.
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   861
 * Useful when copying in a larger amount of text at once
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
   862
 * @param tb Textbuf type which length is calculated
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   863
 */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   864
void UpdateTextBufferSize(Textbuf *tb)
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   865
{
5108
dc67d70b5a45 (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
   866
	const char *buf = tb->buf;
dc67d70b5a45 (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
   867
	WChar c = Utf8Consume(&buf);
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2559
diff changeset
   868
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   869
	tb->width = 0;
5698
6697ee90a195 (svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents: 5682
diff changeset
   870
	tb->length = 0;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   871
5108
dc67d70b5a45 (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
   872
	for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) {
dc67d70b5a45 (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
   873
		tb->width += GetCharacterWidth(FS_NORMAL, c);
5698
6697ee90a195 (svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents: 5682
diff changeset
   874
		tb->length += Utf8CharLen(c);
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   875
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   876
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   877
	tb->caretpos = tb->length;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   878
	tb->caretxoffs = tb->width;
911
bde79514283f (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
   879
}
bde79514283f (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
   880
4909
ef77bf81545c (svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents: 4884
diff changeset
   881
int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
{
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   883
	e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   884
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   885
	switch (e->we.keypress.keycode) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   886
		case WKC_ESC: return 2;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   887
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   888
		case WKC_RETURN: case WKC_NUM_ENTER: return 1;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   889
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   890
		case (WKC_CTRL | 'V'):
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   891
			if (InsertTextBufferClipboard(&string->text)) w->InvalidateWidget(wid);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   892
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   893
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   894
		case (WKC_CTRL | 'U'):
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   895
			DeleteTextBufferAll(&string->text);
8524
baf4ab1ba18d (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8515
diff changeset
   896
			w->InvalidateWidget(wid);
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   897
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   898
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   899
		case WKC_BACKSPACE: case WKC_DELETE:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   900
			if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   901
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   902
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   903
		case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   904
			if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   905
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   906
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   907
		default:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   908
			if (IsValidChar(e->we.keypress.key, string->afilter)) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   909
				if (InsertTextBufferChar(&string->text, e->we.keypress.key)) w->InvalidateWidget(wid);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   910
			} else { // key wasn't caught. Continue only if standard entry specified
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   911
				e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
5108
dc67d70b5a45 (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
   912
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   913
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   914
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   918
bool HandleCaret(Textbuf *tb)
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   919
{
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   920
	/* caret changed? */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   921
	bool b = !!(_caret_timer & 0x20);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   922
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   923
	if (b != tb->caret) {
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   924
		tb->caret = b;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   925
		return true;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   926
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   927
	return false;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   928
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   929
2887
d5967e472eee (svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents: 2873
diff changeset
   930
void HandleEditBox(Window *w, querystr_d *string, int wid)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   931
{
8524
baf4ab1ba18d (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8515
diff changeset
   932
	if (HandleCaret(&string->text)) w->InvalidateWidget(wid);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
2887
d5967e472eee (svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents: 2873
diff changeset
   935
void DrawEditBox(Window *w, querystr_d *string, int wid)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   936
{
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   937
	const Widget *wi = &w->widget[wid];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
9233
4daa9bb8dbf7 (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: 9211
diff changeset
   939
	assert((wi->type & WWT_MASK) == WWT_EDITBOX);
4daa9bb8dbf7 (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: 9211
diff changeset
   940
5890
45bd89352147 (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: 5847
diff changeset
   941
	GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215);
45bd89352147 (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: 5847
diff changeset
   942
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   943
	DrawPixelInfo dpi;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   944
	int delta;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   945
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   946
	/* Limit the drawing of the string inside the widget boundaries */
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   947
	if (!FillDrawPixelInfo(&dpi,
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   948
			wi->left + 4,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   949
			wi->top + 1,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   950
			wi->right - wi->left - 4,
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   951
			wi->bottom - wi->top - 1)) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   952
		return;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
   953
	}
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   954
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   955
	DrawPixelInfo *old_dpi = _cur_dpi;
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   956
	_cur_dpi = &dpi;
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   957
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   958
	/* We will take the current widget length as maximum width, with a small
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   959
	 * space reserved at the end for the caret to show */
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   960
	const Textbuf *tb = &string->text;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
   961
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   962
	delta = (wi->right - wi->left) - tb->width - 10;
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   963
	if (delta > 0) delta = 0;
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   964
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   965
	if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   966
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
   967
	DoDrawString(tb->buf, delta, 0, TC_YELLOW);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
   968
	if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE);
4955
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   969
e3496ee0e37d (svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents: 4949
diff changeset
   970
	_cur_dpi = old_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   973
enum QueryStringWidgets {
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   974
	QUERY_STR_WIDGET_TEXT = 3,
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   975
	QUERY_STR_WIDGET_CANCEL,
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   976
	QUERY_STR_WIDGET_OK
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   977
};
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   978
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   979
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   980
static void QueryStringWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   981
{
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   982
	querystr_d *qs = &WP(w, querystr_d);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   983
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   984
	switch (e->event) {
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   985
		case WE_CREATE:
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   986
			SetBit(_no_scroll, SCROLL_EDIT);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   987
			break;
390
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   988
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   989
		case WE_PAINT:
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   990
			SetDParam(0, qs->caption);
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   991
			DrawWindowWidgets(w);
598
200de7111fa9 (svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents: 596
diff changeset
   992
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   993
			DrawEditBox(w, qs, QUERY_STR_WIDGET_TEXT);
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   994
			break;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   995
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   996
		case WE_CLICK:
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
   997
			switch (e->we.click.widget) {
9233
4daa9bb8dbf7 (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: 9211
diff changeset
   998
				case QUERY_STR_WIDGET_TEXT:
4daa9bb8dbf7 (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: 9211
diff changeset
   999
					ShowOnScreenKeyboard(w, &WP(w, querystr_d), QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK);
4daa9bb8dbf7 (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: 9211
diff changeset
  1000
					break;
4daa9bb8dbf7 (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: 9211
diff changeset
  1001
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1002
				case QUERY_STR_WIDGET_OK:
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1003
		press_ok:;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1004
					if (qs->orig == NULL || strcmp(qs->text.buf, qs->orig) != 0) {
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1005
						Window *parent = w->parent;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1006
						qs->handled = true;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1007
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1008
						/* If the parent is NULL, the editbox is handled by general function
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1009
						 * HandleOnEditText */
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1010
						if (parent != NULL) {
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1011
							WindowEvent e;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1012
							e.event = WE_ON_EDIT_TEXT;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1013
							e.we.edittext.str = qs->text.buf;
10399
79a272c88359 (svn r12941) -Codechange: don't access wndproc directly. Patch by Alberth.
rubidium
parents: 10307
diff changeset
  1014
							parent->HandleWindowEvent(&e);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1015
						} else {
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1016
							HandleOnEditText(qs->text.buf);
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1017
						}
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1018
					}
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1019
					/* Fallthrough */
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1020
				case QUERY_STR_WIDGET_CANCEL:
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1021
					delete w;
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1022
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1023
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1024
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1025
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1026
		case WE_MOUSELOOP:
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1027
			HandleEditBox(w, qs, QUERY_STR_WIDGET_TEXT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1028
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1029
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1030
		case WE_KEYPRESS:
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1031
			switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) {
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1032
				case 1: goto press_ok; // Enter pressed, confirms change
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1033
				case 2: delete w; break; // ESC pressed, closes window, abandons changes
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1034
			}
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1035
			break;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1036
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1037
		case WE_DESTROY: // Call cancellation of query, if we have not handled it before
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1038
			if (!qs->handled && w->parent != NULL) {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1039
				WindowEvent e;
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1040
				Window *parent = w->parent;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1041
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1042
				qs->handled = true;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1043
				e.event = WE_ON_EDIT_TEXT_CANCEL;
10399
79a272c88359 (svn r12941) -Codechange: don't access wndproc directly. Patch by Alberth.
rubidium
parents: 10307
diff changeset
  1044
				parent->HandleWindowEvent(&e);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1045
			}
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8418
diff changeset
  1046
			ClrBit(_no_scroll, SCROLL_EDIT);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1047
			break;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1048
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1049
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1050
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1051
static const Widget _query_string_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1052
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1053
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   259,     0,    13, STR_012D,        STR_NULL},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1054
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   259,    14,    29, 0x0,             STR_NULL},
9233
4daa9bb8dbf7 (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: 9211
diff changeset
  1055
{    WWT_EDITBOX,   RESIZE_NONE,    14,     2,   257,    16,    27, 0x0,             STR_NULL},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1056
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,   129,    30,    41, STR_012E_CANCEL, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
  1057
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   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
  1058
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1059
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1060
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1061
static const WindowDesc _query_string_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
  1062
	190, 219, 260, 42, 260, 42,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
  1063
	WC_QUERY_STRING, WC_NONE,
8515
d0401d967e99 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8514
diff changeset
  1064
	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
  1065
	_query_string_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1066
	QueryStringWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1067
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1068
9233
4daa9bb8dbf7 (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: 9211
diff changeset
  1069
char _edit_str_buf[64];
4daa9bb8dbf7 (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: 9211
diff changeset
  1070
char _orig_str_buf[lengthof(_edit_str_buf)];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1071
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1072
/** Show a query popup window with a textbox in it.
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1073
 * @param str StringID for the text shown in the textbox
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1074
 * @param caption StringID of text shown in caption of querywindow
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1075
 * @param maxlen maximum length in characters allowed. If bit 12 is set we
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1076
 * will not check the resulting string against to original string to return success
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1077
 * @param maxwidth maximum width in pixels allowed
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1078
 * @param parent pointer to a Window that will handle the events (ok/cancel) of this
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1079
 * window. If NULL, results are handled by global function HandleOnEditText
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1080
 * @param afilter filters out unwanted character input */
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1081
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
  1082
{
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1083
	uint realmaxlen = maxlen & ~0x1000;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1084
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1085
	assert(realmaxlen < lengthof(_edit_str_buf));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1086
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1088
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
  1090
	Window *w = new Window(&_query_string_desc);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5680
diff changeset
  1091
	w->parent = parent;
1386
aa5a172a8431 (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
  1092
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4909
diff changeset
  1093
	GetString(_edit_str_buf, str, lastof(_edit_str_buf));
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4948
diff changeset
  1094
	_edit_str_buf[realmaxlen - 1] = '\0';
596
e876d7319634 (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1095
e876d7319634 (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1096
	if (maxlen & 0x1000) {
1386
aa5a172a8431 (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
  1097
		WP(w, querystr_d).orig = NULL;
aa5a172a8431 (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
  1098
	} else {
9233
4daa9bb8dbf7 (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: 9211
diff changeset
  1099
		strecpy(_orig_str_buf, _edit_str_buf, lastof(_orig_str_buf));
4daa9bb8dbf7 (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: 9211
diff changeset
  1100
		WP(w, querystr_d).orig = _orig_str_buf;
1386
aa5a172a8431 (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
  1101
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8450
diff changeset
  1103
	w->LowerWidget(QUERY_STR_WIDGET_TEXT);
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1104
	WP(w, querystr_d).caption = caption;
4299
b86602eaaff1 (svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents: 4293
diff changeset
  1105
	WP(w, querystr_d).afilter = afilter;
4948
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
  1106
	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, realmaxlen, maxwidth);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1108
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1109
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1110
enum QueryWidgets {
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1111
	QUERY_WIDGET_CAPTION = 1,
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1112
	QUERY_WIDGET_NO = 3,
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1113
	QUERY_WIDGET_YES
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1114
};
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1115
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1116
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
  1117
struct query_d {
5724
e6633aa2c817 (svn r7757) -Fix (r7621): x64 did not compile because query_d was too big. Reorder the elements
Darkvater
parents: 5720
diff changeset
  1118
	void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
7503
019993e97f08 (svn r10263) -Fix (r10262): due to 64 bits alignment a struct became a little too large.
rubidium
parents: 7502
diff changeset
  1119
	uint64 params[10];           ///< local copy of _decode_parameters
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1120
	StringID message;            ///< message shown for query window
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1121
	bool calledback;             ///< has callback been executed already (internal usage for WE_DESTROY event)
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
  1122
};
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1123
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d));
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1124
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1125
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1126
static void QueryWndProc(Window *w, WindowEvent *e)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1127
{
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1128
	query_d *q = &WP(w, query_d);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1129
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1130
	switch (e->event) {
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1131
		case WE_PAINT:
7762
03721db0ac1c (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7737
diff changeset
  1132
			CopyInDParam(0, q->params, lengthof(q->params));
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1133
			DrawWindowWidgets(w);
7762
03721db0ac1c (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7737
diff changeset
  1134
			CopyInDParam(0, q->params, lengthof(q->params));
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1135
6523
d41352ca5c1e (svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents: 6516
diff changeset
  1136
			DrawStringMultiCenter(w->width / 2, (w->height / 2) - 10, q->message, w->width - 2);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1137
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1138
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1139
		case WE_CLICK:
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1140
			switch (e->we.click.widget) {
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1141
				case QUERY_WIDGET_YES:
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1142
					q->calledback = true;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1143
					if (q->proc != NULL) q->proc(w->parent, true);
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1144
					/* Fallthrough */
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1145
				case QUERY_WIDGET_NO:
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1146
					delete w;
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1147
					break;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1148
				}
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1149
			break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1150
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1151
		case WE_KEYPRESS: // ESC closes the window, Enter confirms the action
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1152
			switch (e->we.keypress.keycode) {
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1153
				case WKC_RETURN:
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1154
				case WKC_NUM_ENTER:
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1155
					q->calledback = true;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1156
					if (q->proc != NULL) q->proc(w->parent, true);
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1157
					/* Fallthrough */
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1158
				case WKC_ESC:
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1159
					e->we.keypress.cont = false;
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1160
					delete w;
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1161
					break;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1162
			}
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1163
			break;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1164
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1165
		case WE_DESTROY: // Call callback function (if any) on window close if not yet called
5680
b0bae92a1620 (svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents: 5669
diff changeset
  1166
			if (!q->calledback && q->proc != NULL) {
b0bae92a1620 (svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents: 5669
diff changeset
  1167
				q->calledback = true;
b0bae92a1620 (svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents: 5669
diff changeset
  1168
				q->proc(w->parent, false);
b0bae92a1620 (svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents: 5669
diff changeset
  1169
			}
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1170
			break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1171
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1172
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1173
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1174
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1175
static const Widget _query_widgets[] = {
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1176
{  WWT_CLOSEBOX, RESIZE_NONE,  4,   0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW},
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1177
{   WWT_CAPTION, RESIZE_NONE,  4,  11, 209,   0,  13, STR_NULL,        STR_NULL},
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1178
{     WWT_PANEL, RESIZE_NONE,  4,   0, 209,  14,  81, 0x0, /*OVERRIDE*/STR_NULL},
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1179
{WWT_PUSHTXTBTN, RESIZE_NONE,  3,  20,  90,  62,  73, STR_00C9_NO,     STR_NULL},
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1180
{WWT_PUSHTXTBTN, RESIZE_NONE,  3, 120, 190,  62,  73, STR_00C8_YES,    STR_NULL},
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1181
{   WIDGETS_END },
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1182
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1183
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1184
static const WindowDesc _query_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
  1185
	WDP_CENTER, WDP_CENTER, 210, 82, 210, 82,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
  1186
	WC_CONFIRM_POPUP_QUERY, WC_NONE,
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1187
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL,
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1188
	_query_widgets,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1189
	QueryWndProc
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1190
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1191
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1192
/** Show a modal confirmation window with standard 'yes' and 'no' buttons
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1193
 * The window is aligned to the centre of its parent.
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1194
 * NOTE: You cannot use BindCString as parameter for this window!
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1195
 * @param caption string shown as window caption
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1196
 * @param message string that will be shown for the window
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1197
 * @param parent pointer to parent window, if this pointer is NULL the parent becomes
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1198
 * the main window WC_MAIN_WINDOW
6977
67b989528f3d (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6949
diff changeset
  1199
 * @param callback callback function pointer to set in the window descriptor*/
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1200
void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool))
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1201
{
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
  1202
	Window *w = new Window(&_query_desc);
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1203
	if (w == NULL) return;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1204
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1205
	if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1206
	w->parent = parent;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1207
	w->left = parent->left + (parent->width / 2) - (w->width / 2);
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1208
	w->top = parent->top + (parent->height / 2) - (w->height / 2);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1209
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1210
	/* Create a backup of the variadic arguments to strings because it will be
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1211
	 * overridden pretty often. We will copy these back for drawing */
7762
03721db0ac1c (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7737
diff changeset
  1212
	CopyOutDParam(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params));
5669
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1213
	w->widget[QUERY_WIDGET_CAPTION].data = caption;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1214
	WP(w, query_d).message    = message;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1215
	WP(w, query_d).proc       = callback;
ea25407ffa55 (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5568
diff changeset
  1216
	WP(w, query_d).calledback = false;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1217
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1218
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1219
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1220
static const Widget _load_dialog_widgets[] = {
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1221
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1222
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1223
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1224
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1225
{      WWT_PANEL,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,              STR_NULL},
7842
60f0ca823a73 (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: 7837
diff changeset
  1226
{      WWT_PANEL,     RESIZE_RB,    14,     0,   256,    48,   153, 0x0,              STR_NULL},
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1227
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,   STR_SAVELOAD_HOME_BUTTON},
7842
60f0ca823a73 (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: 7837
diff changeset
  1228
{      WWT_INSET,     RESIZE_RB,    14,     2,   243,    50,   151, 0x0,              STR_400A_LIST_OF_DRIVES_DIRECTORIES},
60f0ca823a73 (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: 7837
diff changeset
  1229
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   141, 0x0,              STR_0190_SCROLL_BAR_SCROLLS_LIST},
60f0ca823a73 (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: 7837
diff changeset
  1230
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   245,   256,   142,   153, 0x0,              STR_RESIZE_BUTTON},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1231
{   WIDGETS_END},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1232
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1233
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1234
static const Widget _save_dialog_widgets[] = {
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1235
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1236
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1237
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1238
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1239
{      WWT_PANEL,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,              STR_NULL},
7842
60f0ca823a73 (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: 7837
diff changeset
  1240
{      WWT_PANEL,     RESIZE_RB,    14,     0,   256,    48,   151, 0x0,              STR_NULL},
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1241
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,   STR_SAVELOAD_HOME_BUTTON},
7842
60f0ca823a73 (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: 7837
diff changeset
  1242
{      WWT_INSET,     RESIZE_RB,    14,     2,   243,    50,   150, 0x0,              STR_400A_LIST_OF_DRIVES_DIRECTORIES},
60f0ca823a73 (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: 7837
diff changeset
  1243
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   151, 0x0,              STR_0190_SCROLL_BAR_SCROLLS_LIST},
60f0ca823a73 (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: 7837
diff changeset
  1244
{      WWT_PANEL,    RESIZE_RTB,    14,     0,   256,   152,   167, 0x0,              STR_NULL},
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
  1245
{    WWT_EDITBOX,    RESIZE_RTB,    14,     2,   254,   154,   165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
7842
60f0ca823a73 (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: 7837
diff changeset
  1246
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   127,   168,   179, STR_4003_DELETE,  STR_400C_DELETE_THE_CURRENTLY_SELECTED},
60f0ca823a73 (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: 7837
diff changeset
  1247
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   128,   244,   168,   179, STR_4002_SAVE,    STR_400D_SAVE_THE_CURRENT_GAME_USING},
60f0ca823a73 (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: 7837
diff changeset
  1248
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   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
  1249
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1250
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1252
/* Colors for fios types */
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1253
const TextColour _fios_colors[] = {
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1254
	TC_LIGHT_BLUE, TC_DARK_GREEN,  TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1255
	TC_ORANGE,     TC_LIGHT_BROWN, TC_ORANGE,     TC_ORANGE, TC_YELLOW
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1256
};
2261
3f78323707bb (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2255
diff changeset
  1257
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
  1258
void BuildFileList()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1259
{
1596
c1c439a2d5b2 (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
  1260
	_fios_path_changed = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1261
	FiosFreeSavegameList();
4223
0f9535dda7ed (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
  1262
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1263
	switch (_saveload_mode) {
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1264
		case SLD_NEW_GAME:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1265
		case SLD_LOAD_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1266
		case SLD_SAVE_SCENARIO:
4223
0f9535dda7ed (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
  1267
			_fios_list = FiosGetScenarioList(_saveload_mode); break;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1268
		case SLD_LOAD_HEIGHTMAP:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1269
			_fios_list = FiosGetHeightmapList(_saveload_mode); break;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1270
4223
0f9535dda7ed (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
  1271
		default: _fios_list = FiosGetSavegameList(_saveload_mode); break;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1272
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1274
2100
868d62687c9a (svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents: 2070
diff changeset
  1275
static void DrawFiosTexts(uint maxw)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1276
{
1596
c1c439a2d5b2 (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
  1277
	static const char *path = NULL;
c1c439a2d5b2 (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
  1278
	static StringID str = STR_4006_UNABLE_TO_READ_DRIVE;
c1c439a2d5b2 (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
  1279
	static uint32 tot = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1280
1596
c1c439a2d5b2 (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
  1281
	if (_fios_path_changed) {
c1c439a2d5b2 (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
  1282
		str = FiosGetDescText(&path, &tot);
c1c439a2d5b2 (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
  1283
		_fios_path_changed = false;
c1c439a2d5b2 (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
  1284
	}
c1c439a2d5b2 (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
  1285
c1c439a2d5b2 (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
  1286
	if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1287
	DrawString(2, 37, str, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8246
diff changeset
  1288
	DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1289
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1290
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
  1291
static void MakeSortedSaveGameList()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1292
{
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1293
	uint sort_start = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1294
	uint sort_end = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1295
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1296
	/* Directories are always above the files (FIOS_TYPE_DIR)
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1297
	 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4133
diff changeset
  1298
	 * Only sort savegames/scenarios, not directories
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1299
	 */
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
  1300
	for (int i = 0; i < _fios_num; i++) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1301
		switch (_fios_list[i].type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1302
			case FIOS_TYPE_DIR:    sort_start++; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1303
			case FIOS_TYPE_PARENT: sort_start++; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1304
			case FIOS_TYPE_DRIVE:  sort_end++;   break;
10307
624bb10b4ca8 (svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138
parents: 10233
diff changeset
  1305
			default: break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1306
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1307
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1308
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
  1309
	uint s_amount = _fios_num - sort_start - sort_end;
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
  1310
	if (s_amount > 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1311
		qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems);
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
  1312
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1313
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1314
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
  1315
static void GenerateFileName()
402
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1316
{
9244
59bf7f93c856 (svn r12444) -Fix: A little typo
belugas
parents: 9234
diff changeset
  1317
	/* Check if we are not a spectator who wants to generate a name..
635
5a595bc1653f (svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents: 606
diff changeset
  1318
	    Let's use the name of player #0 for now. */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1319
	const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
635
5a595bc1653f (svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents: 606
diff changeset
  1320
7554
076c42f44a83 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7542
diff changeset
  1321
	SetDParam(0, p->index);
076c42f44a83 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7542
diff changeset
  1322
	SetDParam(1, _date);
4912
d04b3f2bca70 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4909
diff changeset
  1323
	GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf));
7371
b86b05214afe (svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.
rubidium
parents: 7187
diff changeset
  1324
	SanitizeFilename(_edit_str_buf);
402
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1325
}
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1326
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
  1327
extern void StartupEngines();
1131
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1328
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1329
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1330
{
2559
08e648022cb0 (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
  1331
	static FiosItem o_dir;
08e648022cb0 (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
  1332
08e648022cb0 (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
  1333
	switch (e->event) {
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1334
		case WE_CREATE: // Set up OPENTTD button
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1335
			w->vscroll.cap = 10;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1336
			w->resize.step_width = 2;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1337
			w->resize.step_height = 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1338
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1339
			o_dir.type = FIOS_TYPE_DIRECT;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1340
			switch (_saveload_mode) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1341
				case SLD_SAVE_GAME:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1342
				case SLD_LOAD_GAME:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1343
					FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1344
					break;
4000
bab1ebc37da0 (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
  1345
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1346
				case SLD_SAVE_SCENARIO:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1347
				case SLD_LOAD_SCENARIO:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1348
					FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1349
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1350
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1351
				case SLD_LOAD_HEIGHTMAP:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1352
					FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1353
					break;
4000
bab1ebc37da0 (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
  1354
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1355
				default:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1356
					ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1357
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1359
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1360
		case WE_PAINT: {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1361
			int pos;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1362
			int y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1363
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1364
			SetVScrollCount(w, _fios_num);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1365
			DrawWindowWidgets(w);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1366
			DrawFiosTexts(w->width);
2100
868d62687c9a (svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents: 2070
diff changeset
  1367
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1368
			if (_savegame_sort_dirty) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1369
				_savegame_sort_dirty = false;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1370
				MakeSortedSaveGameList();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1371
			}
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1372
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1373
			GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1374
			DrawSortButtonState(w, _savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1375
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1376
			y = w->widget[7].top + 1;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1377
			for (pos = w->vscroll.pos; pos < _fios_num; pos++) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1378
				const FiosItem *item = _fios_list + pos;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1379
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1380
				DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1381
				y += 10;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1382
				if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1383
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1384
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1385
			if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1386
				DrawEditBox(w, &WP(w, querystr_d), 10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1387
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1388
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1389
		}
2559
08e648022cb0 (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
  1390
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1391
		case WE_CLICK:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1392
			switch (e->we.click.widget) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1393
				case 2: // Sort save names by name
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1394
					_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1395
						SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1396
					_savegame_sort_dirty = true;
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
  1397
					w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1398
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1399
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1400
				case 3: // Sort save names by date
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1401
					_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1402
						SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1403
					_savegame_sort_dirty = true;
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
  1404
					w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1405
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1406
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1407
				case 6: // OpenTTD 'button', jumps to OpenTTD directory
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1408
					FiosBrowseTo(&o_dir);
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
  1409
					w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1410
					BuildFileList();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1411
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1412
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1413
				case 7: { // Click the listbox
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1414
					int y = (e->we.click.pt.y - w->widget[e->we.click.widget].top - 1) / 10;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1415
					char *name;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1416
					const FiosItem *file;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1417
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1418
					if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1419
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1420
					file = _fios_list + y;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1421
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1422
					name = FiosBrowseTo(file);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1423
					if (name != NULL) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1424
						if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1425
							_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1426
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1427
							SetFiosType(file->type);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1428
							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1429
							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1430
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1431
							delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1432
						} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1433
							SetFiosType(file->type);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1434
							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1435
							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1436
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1437
							delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1438
							ShowHeightmapLoad();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1439
						} else {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1440
							/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1441
							ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1442
							UpdateTextBufferSize(&WP(w, querystr_d).text);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1443
							w->InvalidateWidget(10);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1444
						}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1445
					} else {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1446
						/* Changed directory, need repaint. */
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
  1447
						w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1448
						BuildFileList();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1449
					}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1450
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1451
				}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1452
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1453
				case 10: // edit box
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1454
					ShowOnScreenKeyboard(w, &WP(w, querystr_d), e->we.click.widget, 0, 0);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1455
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1456
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1457
				case 11: case 12: // Delete, Save game
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1458
					break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1459
			}
9233
4daa9bb8dbf7 (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: 9211
diff changeset
  1460
			break;
4daa9bb8dbf7 (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: 9211
diff changeset
  1461
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1462
		case WE_MOUSELOOP:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1463
			if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1464
				HandleEditBox(w, &WP(w, querystr_d), 10);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1465
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1466
			break;
2165
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1467
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1468
		case WE_KEYPRESS:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1469
			if (e->we.keypress.keycode == WKC_ESC) {
10433
cca9f7948fe5 (svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents: 10429
diff changeset
  1470
				delete w;
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1471
				return;
2255
ddcaf9e333ff (svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents: 2201
diff changeset
  1472
			}
3288
91b3ed6a0885 (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
  1473
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1474
			if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1475
					HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) { // Press Enter
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1476
				w->HandleButtonClick(12);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1477
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1478
			break;
1131
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1479
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1480
		case WE_TIMEOUT:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1481
			/* This test protects against using widgets 11 and 12 which are only available
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1482
			* in those two saveload mode  */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1483
			if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1484
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1485
			if (w->IsWidgetLowered(11)) { // Delete button clicked
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1486
				if (!FiosDelete(WP(w, querystr_d).text.buf)) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1487
					ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1488
				} else {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1489
					BuildFileList();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1490
					/* Reset file name to current date on successful delete */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1491
					if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1492
				}
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1493
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1494
				UpdateTextBufferSize(&WP(w, querystr_d).text);
10434
d6accd017341 (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 10433
diff changeset
  1495
				w->SetDirty();
9234
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1496
			} else if (w->IsWidgetLowered(12)) { // Save button clicked
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1497
				_switch_mode = SM_SAVE;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1498
				FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name));
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1499
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1500
				/* In the editor set up the vehicle engines correctly (date might have changed) */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1501
				if (_game_mode == GM_EDITOR) StartupEngines();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1502
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1503
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1504
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1505
		case WE_DESTROY:
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1506
			/* pause is only used in single-player, non-editor mode, non menu mode */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1507
			if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1508
				if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1509
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1510
			FiosFreeSavegameList();
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1511
			ClrBit(_no_scroll, SCROLL_SAVE);
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1512
			break;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1513
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1514
		case WE_RESIZE: {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1515
			/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1516
			uint diff = e->we.sizing.diff.x / 2;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1517
			w->widget[2].right += diff;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1518
			w->widget[3].left  += diff;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1519
			w->widget[3].right += e->we.sizing.diff.x;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1520
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1521
			/* Same for widget 11 and 12 in save-dialog */
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1522
			if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1523
				w->widget[11].right += diff;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1524
				w->widget[12].left  += diff;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1525
				w->widget[12].right += e->we.sizing.diff.x;
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1526
			}
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1527
8123d1c8e796 (svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents: 9233
diff changeset
  1528
			w->vscroll.cap += e->we.sizing.diff.y / 10;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1529
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1530
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1531
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1532
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1533
static const WindowDesc _load_dialog_desc = {
7842
60f0ca823a73 (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: 7837
diff changeset
  1534
	WDP_CENTER, WDP_CENTER, 257, 154, 257, 294,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
  1535
	WC_SAVELOAD, WC_NONE,
8515
d0401d967e99 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8514
diff changeset
  1536
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1537
	_load_dialog_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1538
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1539
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1540
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1541
static const WindowDesc _save_dialog_desc = {
7842
60f0ca823a73 (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: 7837
diff changeset
  1542
	WDP_CENTER, WDP_CENTER, 257, 180, 257, 320,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6001
diff changeset
  1543
	WC_SAVELOAD, WC_NONE,
8515
d0401d967e99 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8514
diff changeset
  1544
	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
  1545
	_save_dialog_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1546
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1547
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1548
8648
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1549
/** These values are used to convert the file/operations mode into a corresponding file type.
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1550
 * So each entry, as expressed by the related comment, is based on the enum   */
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1551
static const FileType _file_modetotype[] = {
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1552
	FT_SAVEGAME,  ///< used for SLD_LOAD_GAME
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1553
	FT_SCENARIO,  ///< used for SLD_LOAD_SCENARIO
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1554
	FT_SAVEGAME,  ///< used for SLD_SAVE_GAME
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1555
	FT_SCENARIO,  ///< used for SLD_SAVE_SCENARIO
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1556
	FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1557
	FT_SAVEGAME,  ///< SLD_NEW_GAME
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1558
};
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1559
8645
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8640
diff changeset
  1560
void ShowSaveLoadDialog(SaveLoadDialogMode mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1561
{
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1562
	static const StringID saveload_captions[] = {
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1563
		STR_4001_LOAD_GAME,
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1564
		STR_0298_LOAD_SCENARIO,
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1565
		STR_4000_SAVE_GAME,
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1566
		STR_0299_SAVE_SCENARIO,
8920
04df97185061 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8919
diff changeset
  1567
		STR_LOAD_HEIGHTMAP,
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1568
	};
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1569
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1570
	const WindowDesc *sld = &_save_dialog_desc;
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1571
8385
aedd7656cfd1 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 8355
diff changeset
  1572
	SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1575
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1576
	_saveload_mode = mode;
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
  1577
	SetBit(_no_scroll, SCROLL_SAVE);
1397
b04402b901cd (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
  1578
8648
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1579
	/* Use an array to define what will be the current file type being handled
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1580
	 * by current file mode */
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8645
diff changeset
  1581
	_file_to_saveload.filetype = _file_modetotype[mode];
1397
b04402b901cd (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
  1582
	switch (mode) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1583
		case SLD_SAVE_GAME:     GenerateFileName(); break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1584
		case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break;
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1585
		default:                sld = &_load_dialog_desc; break;
1397
b04402b901cd (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
  1586
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1587
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1588
	assert((uint)mode < lengthof(saveload_captions));
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9305
diff changeset
  1589
10461
48556aee54da (svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents: 10445
diff changeset
  1590
	Window *w = new Window(sld);
5079
173056d957f5 (svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents: 5070
diff changeset
  1591
	w->widget[1].data = saveload_captions[mode];
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8450
diff changeset
  1592
	w->LowerWidget(7);
4948
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
  1593
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
  1594
	WP(w, querystr_d).afilter = CS_ALPHANUMERAL;
91dae24f3690 (svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents: 4939
diff changeset
  1595
	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1596
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1597
	/* pause is only used in single-player, non-editor mode, non-menu mode. It
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6523
diff changeset
  1598
	 * will be unpaused in the WE_DESTROY event handler. */
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1599
	if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
9167
a2b146a9be68 (svn r12336) -Fix [FS#1733]: Don't pause/unpause the game when showing load/save windows when the game is paused due to missing GRFs.
peter1138
parents: 9119
diff changeset
  1600
		if (_pause_game >= 0) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1601
	}
278
950c3ac6e649 (svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents: 258
diff changeset
  1602
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1603
	BuildFileList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1604
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1605
	ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1606
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1607
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6565
diff changeset
  1608
void RedrawAutosave()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1609
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1610
	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1611
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1612
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1613
void SetFiosType(const byte fiostype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1614
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1615
	switch (fiostype) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1616
		case FIOS_TYPE_FILE:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1617
		case FIOS_TYPE_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1618
			_file_to_saveload.mode = SL_LOAD;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1619
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1620
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1621
		case FIOS_TYPE_OLDFILE:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1622
		case FIOS_TYPE_OLD_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1623
			_file_to_saveload.mode = SL_OLD_LOAD;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1624
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1625
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1626
#ifdef WITH_PNG
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1627
		case FIOS_TYPE_PNG:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1628
			_file_to_saveload.mode = SL_PNG;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1629
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1630
#endif /* WITH_PNG */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1631
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1632
		case FIOS_TYPE_BMP:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1633
			_file_to_saveload.mode = SL_BMP;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1634
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1635
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1636
		default:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1637
			_file_to_saveload.mode = SL_INVALID;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1638
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1639
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1640
}