misc_gui.c
author matthijs
Wed, 22 Mar 2006 22:26:16 +0000
branch0.4.5
changeset 9958 bed516c67d61
parent 9948 877dccfeb22e
permissions -rw-r--r--
(svn r4041) [Debian] Change next version number to 0.4.6 instead of 0.4.5.1.
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
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1879
diff changeset
     4
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1274
diff changeset
     5
#include "debug.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2162
diff changeset
     6
#include "functions.h"
2340
0a9f3eeccb96 (svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents: 2310
diff changeset
     7
#include "gfxinit.h"
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 2159
diff changeset
     8
#include "saveload.h"
1309
dab90d4cbf2d (svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents: 1304
diff changeset
     9
#include "strings.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1349
diff changeset
    10
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 485
diff changeset
    11
#include "table/strings.h"
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1694
diff changeset
    12
#include "table/tree_land.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 674
diff changeset
    13
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
#include "town.h"
337
66647f97e7c0 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 278
diff changeset
    22
#include "sound.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    23
#include "network.h"
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
    24
#include "string.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2134
diff changeset
    25
#include "variables.h"
1341
3533880da5d5 (svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents: 1336
diff changeset
    26
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    27
#include "hal.h" // for file list
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
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
    29
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
    30
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
    31
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
typedef struct LandInfoData {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	int32 costclear;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	AcceptedCargo ac;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    37
	TileIndex tile;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	TileDesc td;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
} LandInfoData;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
static void LandInfoWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	if (e->event == WE_PAINT) {
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2559
diff changeset
    44
		const LandInfoData* lid;
35249d2ded3e (svn r3172) static, const
tron
parents: 2559
diff changeset
    45
		StringID str;
473
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
    46
		int i;
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
    47
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
		lid = WP(w,void_d).data;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    52
		SetDParam(0, lid->td.dparam[0]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
		DrawStringCentered(140, 16, lid->td.str, 13);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    55
		SetDParam(0, STR_01A6_N_A);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
		if (lid->td.owner != OWNER_NONE && lid->td.owner != OWNER_WATER)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
			GetNameOfOwner(lid->td.owner, lid->tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
		DrawStringCentered(140, 27, STR_01A7_OWNER, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		str = STR_01A4_COST_TO_CLEAR_N_A;
2737
f16e0a808897 (svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents: 2725
diff changeset
    61
		if (!CmdFailed(lid->costclear)) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    62
			SetDParam(0, lid->costclear);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
			str = STR_01A5_COST_TO_CLEAR;
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
		DrawStringCentered(140, 38, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
2426
3362e577adb1 (svn r2952) Querytool output is be 0xAAAA. with leading 0x. Couldn't use # cause that would have written 0X
Darkvater
parents: 2406
diff changeset
    67
		snprintf(_userstring, lengthof(_userstring), "0x%.4X", lid->tile);
926
bd4312619522 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 911
diff changeset
    68
		SetDParam(0, TileX(lid->tile));
bd4312619522 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 911
diff changeset
    69
		SetDParam(1, TileY(lid->tile));
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    70
		SetDParam(2, STR_SPEC_USERSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
		DrawStringCentered(140, 49, STR_LANDINFO_COORDS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    73
		SetDParam(0, STR_01A9_NONE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
		if (lid->town != NULL) {
2070
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
    75
			SetDParam(0, STR_TOWN);
26c657906f25 (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents: 2063
diff changeset
    76
			SetDParam(1, lid->town->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
		DrawStringCentered(140,60, STR_01A8_LOCAL_AUTHORITY, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    80
		{
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    81
			char buf[512];
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    82
			char *p = GetString(buf, STR_01CE_CARGO_ACCEPTED);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    83
			bool found = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    85
			for (i = 0; i < NUM_CARGO; ++i) {
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    86
				if (lid->ac[i] > 0) {
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    87
					// Add a comma between each item.
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    88
					if (found) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    89
						*p++ = ',';
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    90
						*p++ = ' ';
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    91
					}
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    92
					found = true;
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    93
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    94
					// If the accepted value is less than 8, show it in 1/8:ths
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    95
					if (lid->ac[i] < 8) {
2167
99d31f4eeb37 (svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents: 2165
diff changeset
    96
						int32 argv[2];
99d31f4eeb37 (svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents: 2165
diff changeset
    97
						argv[0] = lid->ac[i];
99d31f4eeb37 (svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents: 2165
diff changeset
    98
						argv[1] = _cargoc.names_s[i];
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
    99
						p = GetStringWithArgs(p, STR_01D1_8, argv);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
   100
					} else {
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
   101
						p = GetString(p, _cargoc.names_s[i]);
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
   102
					}
473
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
   103
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   106
			if (found) DrawStringMultiCenter(140, 76, BindCString(buf), 276);
2063
95259a31ceb5 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents: 2049
diff changeset
   107
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   108
71
1b8e15a10515 (svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents: 70
diff changeset
   109
		if (lid->td.build_date != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   110
			SetDParam(0,lid->td.build_date);
71
1b8e15a10515 (svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents: 70
diff changeset
   111
			DrawStringCentered(140,71, STR_BUILD_DATE, 0);
1b8e15a10515 (svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents: 70
diff changeset
   112
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
static const Widget _land_info_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   117
{   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
   118
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   279,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   119
{     WWT_IMGBTN,   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
   120
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
static const WindowDesc _land_info_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	-1, -1, 280, 93,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	WC_LAND_INFO,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	_land_info_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	LandInfoWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   131
static void Place_LandInfo(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	static LandInfoData lid;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	int64 old_money;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
	DeleteWindowById(WC_LAND_INFO, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	w = AllocateWindowDesc(&_land_info_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	WP(w,void_d).data = &lid;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   142
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	lid.tile = tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   146
	p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
3
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   147
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   148
	old_money = p->money64;
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   149
	p->money64 = p->player_money = 0x7fffffff;
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   150
	lid.costclear = DoCommandByTile(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   151
	p->money64 = old_money;
27d9e9fa999a (svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents: 0
diff changeset
   152
	UpdatePlayerMoney32(p);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   153
71
1b8e15a10515 (svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents: 70
diff changeset
   154
	// Becuase build_date is not set yet in every TileDesc, we make sure it is empty
1b8e15a10515 (svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents: 70
diff changeset
   155
	lid.td.build_date = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   156
473
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
   157
	GetAcceptedCargo(tile, lid.ac);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	GetTileDesc(tile, &lid.td);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   159
2898
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   160
		#if defined(_DEBUG)
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   161
		# define LANDINFOD_LEVEL 0
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   162
		#else
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   163
		# define LANDINFOD_LEVEL 1
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   164
		#endif
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   165
		DEBUG(misc, LANDINFOD_LEVEL) ("TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   166
		DEBUG(misc, LANDINFOD_LEVEL) ("type_height  = %#x", _m[tile].type_height);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   167
		DEBUG(misc, LANDINFOD_LEVEL) ("m1           = %#x", _m[tile].m1);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   168
		DEBUG(misc, LANDINFOD_LEVEL) ("m2           = %#x", _m[tile].m2);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   169
		DEBUG(misc, LANDINFOD_LEVEL) ("m3           = %#x", _m[tile].m3);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   170
		DEBUG(misc, LANDINFOD_LEVEL) ("m4           = %#x", _m[tile].m4);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   171
		DEBUG(misc, LANDINFOD_LEVEL) ("m5           = %#x", _m[tile].m5);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   172
		DEBUG(misc, LANDINFOD_LEVEL) ("extra        = %#x", _m[tile].extra);
d94c5f6368f0 (svn r3453) - CodeChange: Also show the landinfo debug information when building in release mode; however it is shown at debug level 1.
Darkvater
parents: 2887
diff changeset
   173
		#undef LANDINFOD_LEVEL
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
   176
void PlaceLandBlockInfo(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   178
	if (_cursor.sprite == SPR_CURSOR_QUERY) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
		_place_proc = Place_LandInfo;
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   182
		SetObjectToPlace(SPR_CURSOR_QUERY, 1, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   186
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
   187
	/*************************************************************************
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   188
	 *                      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
   189
	"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
   190
	"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
   191
	"",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   192
	"The OpenTTD team (in alphabetical order):",
2310
ce948102d659 (svn r2836) fixed the alphabetical order of the credits list like it says it is in
bjarni
parents: 2275
diff changeset
   193
	"  Bjarni Corfitzen (Bjarni) - MacOSX port, coder",
1826
d123cb6b11dc (svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents: 1821
diff changeset
   194
	"  Matthijs Kooijman (blathijs) - Pathfinder-god",
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   195
	"  Victor Fischer (Celestar) - Programming everywhere you need him to",
2134
7192d5266a96 (svn r2644) - Fix: my name was mistyped ;p
Darkvater
parents: 2128
diff changeset
   196
	"  Tamás Faragó (Darkvater) - Lead coder",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   197
	"  Kerekes Miham (MiHaMiX) - Translator system, and Nightlies host",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   198
	"  Owen Rudge (orudge) - Forum- and masterserver host, OS/2 port",
2748
b5c4fbeadf6d (svn r3293) - Miscellaneous: add peter1138 as developer
Darkvater
parents: 2737
diff changeset
   199
	"  Peter Nelson (peter1138) - Spiritual descendant from newgrf gods",
1126
5d778d55d094 (svn r1627) -Fix: The tabulizer in action ^_^
darkvater
parents: 1125
diff changeset
   200
	"  Christoph Mallon (Tron) - Programmer, code correctness police",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   201
	"  Patric Stout (TrueLight) - Coder, network guru, SVN- and website host",
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   202
	"",
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   203
	"Retired Developers:",
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   204
	"  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
   205
	"  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
   206
	"  Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   207
	"",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   208
	"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
   209
	"  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
   210
	"  Marcin Grzegorczyk - For his documentation of TTD internals",
1577
6528a7b4e180 (svn r2081) I have a real name, too.
pasky
parents: 1556
diff changeset
   211
	"  Petr Baudis (pasky) - Many patches, newgrf support",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   212
	"  Stefan Meißner (sign_de) - For his work on the console",
1826
d123cb6b11dc (svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents: 1821
diff changeset
   213
	"  Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with (and PBS)",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   214
	"  Cian Duffy (MYOB) - BeOS port / manual writing",
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   215
	"  Christian Rosentreter (tokaiz) - MorphOS / AmigaOS port",
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   216
	"",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   217
	"  Michael Blunck - Pre-Signals and Semaphores © 2003",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   218
	"  George - Canal/Lock graphics © 2003-2004",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   219
	"  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
   220
	"  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
   221
	"  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
   222
	"",
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   223
	"",
1124
01fc35434ed6 (svn r1625) -Alphabetized credits list
darkvater
parents: 1105
diff changeset
   224
	"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
   225
	"  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
   226
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
static void AboutWindowProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   230
	switch (e->event) {
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   231
	case WE_CREATE: /* Set up window counter and start position of scroller */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   232
		WP(w, scroller_d).counter = 0;
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   233
		WP(w, scroller_d).height = w->height - 40;
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   234
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	case WE_PAINT: {
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 926
diff changeset
   236
		uint i;
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   237
		int y = WP(w, scroller_d).height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   240
		// Show original copyright and revision version
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   241
		DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0);
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   242
		DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, 0);
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   243
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   244
		// Show all scrolling credits
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   245
		for (i = 0; i < lengthof(credits); i++) {
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   246
			if (y >= 50 && y < (w->height - 40)) {
1392
7b08188ca3be (svn r1896) - Fix: remove Translated by hack since it's not used
Darkvater
parents: 1390
diff changeset
   247
				DoDrawString(credits[i], 10, y, 0x10);
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   248
			}
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   249
			y += 10;
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   250
		}
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   251
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   252
		// If the last text has scrolled start anew from the start
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   253
		if (y < 50) WP(w, scroller_d).height = w->height - 40;
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   254
2134
7192d5266a96 (svn r2644) - Fix: my name was mistyped ;p
Darkvater
parents: 2128
diff changeset
   255
		DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", 16);
7192d5266a96 (svn r2644) - Fix: my name was mistyped ;p
Darkvater
parents: 2128
diff changeset
   256
		DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, 0);
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   257
	}	break;
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   258
	case WE_MOUSELOOP: /* Timer to scroll the text and adjust the new top */
998
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   259
		if (WP(w, scroller_d).counter++ % 3 == 0) {
d9dc257b8949 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 980
diff changeset
   260
			WP(w, scroller_d).height--;
859
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   261
			SetWindowDirty(w);
46839573bed8 (svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents: 842
diff changeset
   262
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
static const Widget _about_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   268
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   269
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   419,     0,    13, STR_015B_OPENTTD,	STR_NULL},
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   270
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   419,    14,   271, 0x0,								STR_NULL},
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   271
{      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
   272
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
static const WindowDesc _about_desc = {
1125
34615a848111 (svn r1626) -Updated readme and credits list.
darkvater
parents: 1124
diff changeset
   276
	WDP_CENTER, WDP_CENTER, 420, 272,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	WC_GAME_OPTIONS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	_about_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	AboutWindowProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
   284
void ShowAboutWindow(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
	AllocateWindowDesc(&_about_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
static int _tree_to_plant;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
static const uint32 _tree_sprites[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	0x655,0x663,0x678,0x62B,0x647,0x639,0x64E,0x632,0x67F,0x68D,0x69B,0x6A9,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	0x6AF,0x6D2,0x6D9,0x6C4,0x6CB,0x6B6,0x6BD,0x6E0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	0x72E,0x734,0x74A,0x74F,0x76B,0x78F,0x788,0x77B,0x75F,0x774,0x720,0x797,
2187
2a51f8925eeb (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents: 2186
diff changeset
   296
	0x79E,0x7A5 | PALETTE_TO_GREEN,0x7AC | PALETTE_TO_RED,0x7B3,0x7BA,0x7C1 | PALETTE_TO_RED,0x7C8 | PALETTE_TO_PALE_GREEN,0x7CF | PALETTE_TO_YELLOW,0x7D6 | PALETTE_TO_RED
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
static void BuildTreesWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   301
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
		int x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
		int i, count;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
		DrawWindowWidgets(w);
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
		WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
		WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		x = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		y = 54;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
			DrawSprite(_tree_sprites[i], x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
			x += 35;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
			if (!(++i & 3)) {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   317
				x -= 35 * 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
				y += 47;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
		} while (--count);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	case WE_CLICK: {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   324
		int wid = e->click.widget;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   326
		switch (wid) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		case 0:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
			ResetObjectToPlace();
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   329
			break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   330
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
		case 3: case 4: case 5: case 6:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
		case 7: case 8: case 9: case 10:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
		case 11:case 12: case 13: case 14:
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   334
			if (wid - 3 >= WP(w,tree_d).count) break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   335
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   336
			if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
				_tree_to_plant = WP(w,tree_d).base + wid - 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
		case 15: // tree of random type.
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   341
			if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, 1, NULL))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
				_tree_to_plant = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
		case 16: /* place trees randomly over the landscape*/
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
			w->click_state |= 1 << 16;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   348
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
			PlaceTreesRandomly();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   354
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	case WE_PLACE_OBJ:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
		VpStartPlaceSizing(e->place.tile, VPM_X_AND_Y_LIMITED);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
		VpSetPlaceSizingLimit(20);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	case WE_PLACE_DRAG:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
		VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
	case WE_PLACE_MOUSEUP:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
		if (e->click.pt.x != -1) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   366
			DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
				CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	case WE_TIMEOUT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
		UnclickSomeWindowButtons(w, 1<<16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
	case WE_ABORT_PLACE_OBJ:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
		w->click_state = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
}
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
static const Widget _build_trees_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   383
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   384
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   142,     0,    13, STR_2802_TREES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   385
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   142,    14,   170, 0x0,							STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   386
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   387
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   388
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   389
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   390
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   391
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   392
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   393
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   394
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   395
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   396
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   397
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   398
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   2,   140,   157,   168, STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   399
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
static const WindowDesc _build_trees_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	497, 22, 143, 171,
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 598
diff changeset
   404
	WC_BUILD_TREES, WC_SCEN_LAND_GEN,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
	_build_trees_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
	BuildTreesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
static const Widget _build_trees_scen_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   411
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   412
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   142,     0,    13, STR_2802_TREES,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   413
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   142,    14,   183, 0x0,							STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   414
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   415
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   416
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   417
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,    16,    61, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   418
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   419
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   420
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   421
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,    63,   108, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   422
{      WWT_PANEL,   RESIZE_NONE,    14,     2,    35,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   423
{      WWT_PANEL,   RESIZE_NONE,    14,    37,    70,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   424
{      WWT_PANEL,   RESIZE_NONE,    14,    72,   105,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   425
{      WWT_PANEL,   RESIZE_NONE,    14,   107,   140,   110,   155, 0x0,							STR_280D_SELECT_TREE_TYPE_TO_PLANT},
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   426
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   140,   157,   168, STR_TREES_RANDOM_TYPE,	STR_TREES_RANDOM_TYPE_TIP},
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   427
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   140,   170,   181, STR_028A_RANDOM_TREES,	STR_028B_PLANT_TREES_RANDOMLY_OVER},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
   428
{    WIDGETS_END},
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
static const WindowDesc _build_trees_scen_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	-1, -1, 143, 184,
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 598
diff changeset
   433
	WC_BUILD_TREES,0,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
	_build_trees_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
	BuildTreesWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   439
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
   440
void ShowBuildTreesToolbar(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
{
1846
c4c9ded67c3c (svn r2351) -Fix: It was possible to open more than one tree window
tron
parents: 1843
diff changeset
   442
	AllocateWindowDescFront(&_build_trees_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
   445
void ShowBuildTreesScenToolbar(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	AllocateWindowDescFront(&_build_trees_scen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
674
63eb544b0689 (svn r1112) -Fix: _decode_parameters was increased to [20], but not all temp-dparams were
truelight
parents: 635
diff changeset
   450
static uint32 _errmsg_decode_params[20];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
static StringID _errmsg_message_1, _errmsg_message_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
static uint _errmsg_duration;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
static const Widget _errmsg_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   456
{   WWT_CLOSEBOX,   RESIZE_NONE,     4,     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
   457
{    WWT_CAPTION,   RESIZE_NONE,     4,    11,   239,     0,    13, STR_00B2_MESSAGE,	STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   458
{      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
   459
{    WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
static const Widget _errmsg_face_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
   463
{   WWT_CLOSEBOX,   RESIZE_NONE,     4,     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
   464
{    WWT_CAPTION,   RESIZE_NONE,     4,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM,	STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   465
{      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
   466
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
static void ErrmsgWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   471
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
		COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params));
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   476
		if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
			DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
				120,
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   479
				(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
				_errmsg_message_2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
				238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
			if (_errmsg_message_1 != INVALID_STRING_ID)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
				DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
					120,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
					30,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
					_errmsg_message_1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
					238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
		} else {
2475
8443e1eefe1b (svn r3001) s/Player*/const Player*/
tron
parents: 2426
diff changeset
   489
			const Player* p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
			DrawPlayerFace(p->face, p->player_color, 2, 16);
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
			DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
				214,
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   494
				(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
				_errmsg_message_2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
				238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
			if (_errmsg_message_1 != INVALID_STRING_ID)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
				DrawStringMultiCenter(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
					214,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
					90,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
					_errmsg_message_1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
					238);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
	case WE_MOUSELOOP:
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   507
		if (_right_button_down) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
		break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   509
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
	case WE_4:
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   511
		if (--_errmsg_duration == 0) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   513
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   514
	case WE_DESTROY:
1860
cc0019652d0e (svn r2366) Use SetRedErrorSquare() instead of home brewed version
tron
parents: 1846
diff changeset
   515
		SetRedErrorSquare(0);
172
8d8b3383470d (svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents: 155
diff changeset
   516
		_switch_mode_errorstr = INVALID_STRING_ID;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
	case WE_KEYPRESS:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
		if (e->keypress.keycode == WKC_SPACE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
			// Don't continue.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
			e->keypress.cont = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
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
   530
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
	ViewPort *vp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
	Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
	DeleteWindowById(WC_ERRMSG, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
	//assert(msg_2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
	if (msg_2 == 0) msg_2 = STR_EMPTY;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	_errmsg_message_1 = msg_1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
	_errmsg_message_2 = msg_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
	COPY_OUT_DPARAM(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
	_errmsg_duration = _patches.errmsg_duration;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
	if (!_errmsg_duration)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
		return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   546
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   547
	if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
		if ( (x|y) != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
			pt = RemapCoords2(x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
			for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
			vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
			// move x pos to opposite corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
			pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
			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
   557
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
			// move y pos to opposite corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
			pt.y = ((pt.y - vp->virtual_top) >> vp->zoom) + vp->top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
			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
   561
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
			pt.x = (_screen.width - 240) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
			pt.y = (_screen.height - 46) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
		w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
		if ( (x|y) != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
			pt = RemapCoords2(x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
			for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
			vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
			pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
			pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
			pt.x = (_screen.width - 334) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
			pt.y = (_screen.height - 137) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
		w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
	w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
void ShowEstimatedCostOrIncome(int32 cost, int x, int y)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
{
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
   587
	StringID msg = STR_0805_ESTIMATED_COST;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
		msg = STR_0807_ESTIMATED_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
	}
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   593
	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
   594
	ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
{
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
   599
	StringID msg;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	Point pt = RemapCoords(x,y,z);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
	msg = STR_0801_COST;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
	if (cost < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
		cost = -cost;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
		msg = STR_0803_INCOME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
	}
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   607
	SetDParam(0, cost);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
	AddTextEffect(msg, pt.x, pt.y, 0x250);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   611
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost)
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   612
{
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   613
	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
   614
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   615
	SetDParam(0, cost);
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   616
	AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250);
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   617
}
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1914
diff changeset
   618
2275
cbaeb07740b1 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   619
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
   620
{      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
   621
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
static void TooltipsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   627
	switch (e->event) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   628
		case WE_PAINT:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   629
			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   630
			GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   631
			DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w,tooltips_d).string_id, 197);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   632
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   634
		case WE_MOUSELOOP:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   635
			if (!_right_button_down) DeleteWindow(w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   636
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
}
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
void GuiShowTooltips(StringID string_id)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
   642
	char buffer[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
	int right,bottom;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
	int x,y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   646
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   647
	if (string_id == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
	w = FindWindowById(WC_TOOLTIPS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
	if (w != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
		if (WP(w,tooltips_d).string_id == string_id)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
		DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
   656
	GetString(buffer, string_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
   658
	right = GetStringWidth(buffer) + 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
	bottom = 14;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
	if (right > 200) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
		bottom += ((right - 4) / 176) * 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
		right = 200;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
	y = _cursor.pos.y + 30;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
	if (y < 22) y = 22;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
	if (y > (_screen.height - 44) && (y-=52) > (_screen.height - 44))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
		y = (_screen.height - 44);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
	x = _cursor.pos.x - (right >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
	if (x < 0) x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
	if (x > (_screen.width - right)) x = _screen.width - right;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
	w = AllocateWindow(x, y, right, bottom, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
	WP(w,tooltips_d).string_id = string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
2275
cbaeb07740b1 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   679
	w->widget[0].right = right;
cbaeb07740b1 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   680
	w->widget[0].bottom = bottom;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   684
static void DrawStationCoverageText(const AcceptedCargo accepts,
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   685
	int str_x, int str_y, uint mask)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
{
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   687
	char *b = _userstring;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
	int i;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   689
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1500
diff changeset
   690
	b = InlineString(b, STR_000D_ACCEPTS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   692
	for (i = 0; i != NUM_CARGO; i++, mask >>= 1) {
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   693
		if (accepts[i] >= 8 && mask & 1) {
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   694
			b = InlineString(b, _cargoc.names_s[i]);
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1500
diff changeset
   695
			*b++ = ',';
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1500
diff changeset
   696
			*b++ = ' ';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
1329
a8a0d60b0a8e (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
   700
	if (b == &_userstring[3]) {
1553
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1500
diff changeset
   701
		b = InlineString(b, STR_00D0_NOTHING);
4976359e2bf9 (svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents: 1500
diff changeset
   702
		*b++ = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
	} else {
1556
4fd2c95e6bc4 (svn r2060) Clean up some string construction and remove now unused macro
tron
parents: 1553
diff changeset
   704
		b[-2] = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
	DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
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
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   710
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) {
2873
75b688d160d5 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   711
	TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
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
   712
	AcceptedCargo accepts;
2873
75b688d160d5 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   713
	if (tile < MapSize()) {
75b688d160d5 (svn r3421) - Revert r3412 as it didn't work.
peter1138
parents: 2753
diff changeset
   714
		GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / 16, _thd.size.y / 16 , rad);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
		DrawStationCoverageText(accepts, sx, sy, mask);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   719
void CheckRedrawStationCoverage(const Window* w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   721
	if (_thd.dirty & 1) {
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   722
		_thd.dirty &= ~1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
void UnclickSomeWindowButtons(Window *w, uint32 mask)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
	uint32 x = w->click_state & mask;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   731
	int i = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
	w->click_state ^= x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
	do {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   734
		if (x & 1) InvalidateWidget(w, i);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
   735
	} while (i++, x >>= 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
void UnclickWindowButtons(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
	UnclickSomeWindowButtons(w, (uint32)-1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
void SetVScrollCount(Window *w, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
	w->vscroll.count = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
	num -= w->vscroll.cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
	if (num < 0) num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
	if (num < w->vscroll.pos) w->vscroll.pos = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   752
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   753
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
   754
{
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   755
	w->vscroll2.count = num;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   756
	num -= w->vscroll2.cap;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   757
	if (num < 0) num = 0;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   758
	if (num < w->vscroll2.pos) w->vscroll2.pos = num;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   759
}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 755
diff changeset
   760
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
void SetHScrollCount(Window *w, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
	w->hscroll.count = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
	num -= w->hscroll.cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
	if (num < 0) num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
	if (num < w->hscroll.pos) w->hscroll.pos = num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
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
   769
static void DelChar(Textbuf *tb)
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
   770
{
1419
6d94ac953371 (svn r1923) - Fix: [ 1155696 ] Crash with german umlauts in station names. The width was not calculated using unsigned values, so all characters above 128 were "negative"
Darkvater
parents: 1397
diff changeset
   771
	tb->width -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
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
	memmove(tb->buf + tb->caretpos, tb->buf + tb->caretpos + 1, tb->length - tb->caretpos);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   773
	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
   774
}
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
   775
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
   776
/**
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   777
 * 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
   778
 * The character is delete from the position the caret is at
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   779
 * @param tb @Textbuf type to be 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
   780
 * @param delmode Type of deletion, either @WKC_BACKSPACE or @WKC_DELETE
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   781
 * @return Return true on successfull change of Textbuf, or false otherwise
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
 */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   783
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
   784
{
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
	if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
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
		tb->caretpos--;
1419
6d94ac953371 (svn r1923) - Fix: [ 1155696 ] Crash with german umlauts in station names. The width was not calculated using unsigned values, so all characters above 128 were "negative"
Darkvater
parents: 1397
diff changeset
   787
		tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
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
   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
		DelChar(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
   790
		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
   791
	} else if (delmode == WKC_DELETE && 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
   792
		DelChar(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
   793
		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
   794
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   795
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
	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
   797
}
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
/**
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
   800
 * Delete every character in the textbuffer
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
   801
 * @param tb @Textbuf buffer to be emptied
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
   802
 */
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
   803
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
   804
{
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
   805
	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
   806
	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
   807
	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
   808
}
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
   809
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
   810
/**
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
   811
 * Insert a character to a textbuffer. If maxlength is zero, we don't care about
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   812
 * the screenlength but only about the physical length of the string
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   813
 * @param tb @Textbuf type to be 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
   814
 * @param key Character to be inserted
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   815
 * @return Return true on successfull change of Textbuf, or false otherwise
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   816
 */
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   817
bool InsertTextBufferChar(Textbuf *tb, byte key)
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   818
{
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   819
	const byte charwidth = GetCharacterWidth(key);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   820
	if (tb->length < tb->maxlength && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) {
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
   821
		memmove(tb->buf + tb->caretpos + 1, tb->buf + tb->caretpos, (tb->length - tb->caretpos) + 1);
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
   822
		tb->buf[tb->caretpos] = key;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   823
		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
   824
		tb->width += 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
   825
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
		tb->caretpos++;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   827
		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
   828
		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
   829
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   830
	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
   831
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   832
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   833
/**
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   834
 * 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
   835
 * This defines where the caret will blink and the next characer interaction will occur
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
 * @param tb @Textbuf type where navigation occurs
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
 * @param navmode Direction in which navigation occurs @WKC_LEFT, @WKC_RIGHT, @WKC_END, @WKC_HOME
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
 * @return Return true on successfull change of Textbuf, or false otherwise
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
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
   841
{
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   842
	switch (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
   843
	case WKC_LEFT:
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   844
		if (tb->caretpos != 0) {
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   845
			tb->caretpos--;
1419
6d94ac953371 (svn r1923) - Fix: [ 1155696 ] Crash with german umlauts in station names. The width was not calculated using unsigned values, so all characters above 128 were "negative"
Darkvater
parents: 1397
diff changeset
   846
			tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
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
   847
			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
   848
		}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   849
		break;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   850
	case WKC_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
   851
		if (tb->caretpos < tb->length) {
1419
6d94ac953371 (svn r1923) - Fix: [ 1155696 ] Crash with german umlauts in station names. The width was not calculated using unsigned values, so all characters above 128 were "negative"
Darkvater
parents: 1397
diff changeset
   852
			tb->caretxoffs += GetCharacterWidth((byte)tb->buf[tb->caretpos]);
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
   853
			tb->caretpos++;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   854
			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
   855
		}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   856
		break;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   857
	case WKC_HOME:
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   858
		tb->caretpos = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   859
		tb->caretxoffs = 0;
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
		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
   861
	case WKC_END:
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   862
		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
   863
		tb->caretxoffs = tb->width;
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
		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
   865
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   866
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   867
	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
   868
}
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
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   870
/**
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
 * Update @Textbuf type with its actual physical character and screenlength
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   872
 * 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
   873
 * Useful when copying in a larger amount of text at once
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   874
 * @param tb @Textbuf type which length is calculated
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
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
   877
{
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2559
diff changeset
   878
	const char* buf;
35249d2ded3e (svn r3172) static, const
tron
parents: 2559
diff changeset
   879
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
   880
	tb->length = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   881
	tb->width = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   882
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   883
	for (buf = tb->buf; *buf != '\0' && tb->length <= tb->maxlength; buf++) {
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   884
		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
   885
		tb->width += GetCharacterWidth((byte)*buf);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   886
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   887
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   888
	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
   889
	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
   890
}
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
   891
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
   892
int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   893
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   894
	we->keypress.cont = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   895
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
   896
	switch (we->keypress.keycode) {
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   897
	case WKC_ESC: return 2;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   898
	case WKC_RETURN: case WKC_NUM_ENTER: return 1;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   899
	case (WKC_CTRL | 'V'):
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
   900
		if (InsertTextBufferClipboard(&string->text))
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
   901
			InvalidateWidget(w, wid);
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
   902
		break;
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
   903
	case (WKC_CTRL | 'U'):
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
   904
		DeleteTextBufferAll(&string->text);
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
   905
		InvalidateWidget(w, wid);
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
   906
		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
   907
	case WKC_BACKSPACE: case WKC_DELETE:
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
   908
		if (DeleteTextBufferChar(&string->text, we->keypress.keycode))
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
   909
			InvalidateWidget(w, wid);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   910
		break;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   911
	case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
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
   912
		if (MoveTextBufferPos(&string->text, we->keypress.keycode))
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
   913
			InvalidateWidget(w, wid);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   914
  	break;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   915
	default:
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   916
		if (IsValidAsciiChar(we->keypress.ascii)) {
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
   917
			if (InsertTextBufferChar(&string->text, we->keypress.ascii))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   918
				InvalidateWidget(w, wid);
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
   919
		} else // key wasn't caught
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
			we->keypress.cont = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   923
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   924
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
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
   926
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
   927
{
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
	/* 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
   929
	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
   930
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   931
	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
   932
		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
   933
		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
   934
	}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   935
	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
   936
}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
   937
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
   938
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
   939
{
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
   940
	if (HandleCaret(&string->text)) InvalidateWidget(w, wid);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   941
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
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
   943
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
   944
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
	const Widget *wi = w->widget + wid;
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
   946
	const Textbuf *tb = &string->text;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   948
	GfxFillRect(wi->left+1, wi->top+1, wi->right-1, wi->bottom-1, 215);
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
   949
	DoDrawString(tb->buf, wi->left+2, wi->top+1, 8);
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
   950
	if (tb->caret) DoDrawString("_", wi->left + 2 + tb->caretxoffs, wi->top + 1, 12);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   951
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
static void QueryStringWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   955
	static bool closed = false;
1843
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   956
	switch (e->event) {
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   957
	case WE_CREATE:
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   958
		SETBIT(_no_scroll, SCROLL_EDIT);
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   959
		closed = false;
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   960
		break;
733f83b6483a (svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents: 1826
diff changeset
   961
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
   962
	case WE_PAINT:
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   963
		SetDParam(0, WP(w,querystr_d).caption);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   964
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   965
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
   966
		DrawEditBox(w, &WP(w,querystr_d), 5);
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
   967
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   968
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   969
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
		case 3: DeleteWindow(w); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
		case 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   973
press_ok:;
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
   974
			if (WP(w, querystr_d).orig != NULL &&
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
   975
					strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).orig) == 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   976
				DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   977
			} else {
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
   978
				char *buf = WP(w,querystr_d).text.buf;
390
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   979
				WindowClass wnd_class = WP(w,querystr_d).wnd_class;
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   980
				WindowNumber wnd_num = WP(w,querystr_d).wnd_num;
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   981
				Window *parent;
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   982
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   983
				// Mask the edit-box as closed, so we don't send out a CANCEL
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   984
				closed = true;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   985
598
200de7111fa9 (svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents: 596
diff changeset
   986
				DeleteWindow(w);
200de7111fa9 (svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents: 596
diff changeset
   987
390
672930cad487 (svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents: 337
diff changeset
   988
				parent = FindWindowById(wnd_class, wnd_num);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   989
				if (parent != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
					WindowEvent e;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
					e.event = WE_ON_EDIT_TEXT;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   992
					e.edittext.str = buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
					parent->wndproc(parent, &e);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   994
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   995
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   996
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   997
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   998
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   999
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1000
	case WE_MOUSELOOP: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1001
		if (!FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1002
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1003
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1004
		}
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
  1005
		HandleEditBox(w, &WP(w, querystr_d), 5);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1007
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
	case WE_KEYPRESS: {
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
  1009
		switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1010
		case 1: // Return
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1011
			goto press_ok;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
		case 2: // Escape
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1015
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1016
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
	case WE_DESTROY:
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1019
		// If the window is not closed yet, it means it still needs to send a CANCEL
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1020
		if (!closed) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1021
			Window *parent = FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1022
			if (parent != NULL) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1023
				WindowEvent e;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1024
				e.event = WE_ON_EDIT_TEXT_CANCEL;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1025
				parent->wndproc(parent, &e);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1026
			}
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1027
		}
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
  1028
		CLRBIT(_no_scroll, SCROLL_EDIT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1029
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1032
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
static const Widget _query_string_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1034
{   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
  1035
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   259,     0,    13, STR_012D,				STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1036
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   259,    14,    29, 0x0,							STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1037
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,   129,    30,    41, STR_012E_CANCEL,	STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1038
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   130,   259,    30,    41, STR_012F_OK,			STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1039
{     WWT_IMGBTN,   RESIZE_NONE,    14,     2,   257,    16,    27, 0x0,							STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
  1040
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1042
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1043
static const WindowDesc _query_string_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1044
	190, 219, 260, 42,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1045
	WC_QUERY_STRING,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1046
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1047
	_query_string_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1048
	QueryStringWndProc
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
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
  1051
static char _edit_str_buf[64];
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
  1052
static char _orig_str_buf[lengthof(_edit_str_buf)];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
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
  1054
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1055
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
	Window *w;
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
  1057
	uint realmaxlen = maxlen & ~0x1000;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
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
  1059
	assert(realmaxlen < lengthof(_edit_str_buf));
0
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
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1062
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1063
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
  1064
	w = AllocateWindowDesc(&_query_string_desc);
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
  1065
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
  1066
	GetString(_edit_str_buf, str);
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
  1067
	_edit_str_buf[realmaxlen] = '\0';
596
e876d7319634 (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1068
e876d7319634 (svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents: 568
diff changeset
  1069
	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
  1070
		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
  1071
	} else {
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
  1072
		strcpy(_orig_str_buf, _edit_str_buf);
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
  1073
		WP(w, querystr_d).orig = _orig_str_buf;
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
  1074
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1075
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1076
	w->click_state = 1 << 5;
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
  1077
	WP(w, querystr_d).caption = caption;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1078
	WP(w, querystr_d).wnd_class = window_class;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1079
	WP(w, querystr_d).wnd_num = window_number;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1080
	WP(w, querystr_d).text.caret = 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
  1081
	WP(w, querystr_d).text.maxlength = realmaxlen - 1;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1082
	WP(w, querystr_d).text.maxwidth = maxwidth;
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
	WP(w, querystr_d).text.buf = _edit_str_buf;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1084
	UpdateTextBufferSize(&WP(w, querystr_d).text);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1085
}
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
static const Widget _load_dialog_1_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1088
{   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
  1089
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_4001_LOAD_GAME,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1090
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME,		STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1091
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE,		STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1092
{     WWT_IMGBTN,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1093
{     WWT_IMGBTN,     RESIZE_RB,    14,     0,   256,    48,   293, 0x0,								STR_NULL},
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1094
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,			STR_SAVELOAD_HOME_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1095
{          WWT_6,     RESIZE_RB,    14,     2,   243,    50,   291, 0x0,								STR_400A_LIST_OF_DRIVES_DIRECTORIES},
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
  1096
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   281, 0x0,								STR_0190_SCROLL_BAR_SCROLLS_LIST},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1097
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   245,   256,   282,   293, 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
  1098
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1099
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
static const Widget _load_dialog_2_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1102
{   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
  1103
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_0298_LOAD_SCENARIO,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1104
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME,				STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1105
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE,				STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1106
{     WWT_IMGBTN,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,										STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1107
{     WWT_IMGBTN,     RESIZE_RB,    14,     0,   256,    48,   293, 0x0,										STR_NULL},
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1108
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,					STR_SAVELOAD_HOME_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1109
{          WWT_6,     RESIZE_RB,    14,     2,   243,    50,   291, 0x0,										STR_400A_LIST_OF_DRIVES_DIRECTORIES},
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
  1110
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   281, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1111
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   245,   256,   282,   293, 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
  1112
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1113
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
static const Widget _save_dialog_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1116
{   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
  1117
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_4000_SAVE_GAME,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1118
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME,		STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1119
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE,		STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1120
{     WWT_IMGBTN,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1121
{     WWT_IMGBTN,     RESIZE_RB,    14,     0,   256,    48,   291, 0x0,								STR_NULL},
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1122
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,			STR_SAVELOAD_HOME_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1123
{          WWT_6,     RESIZE_RB,    14,     2,   243,    50,   290, 0x0,								STR_400A_LIST_OF_DRIVES_DIRECTORIES},
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
  1124
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   291, 0x0,								STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1125
{     WWT_IMGBTN,    RESIZE_RTB,    14,     0,   256,   292,   307, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1126
{     WWT_IMGBTN,    RESIZE_RTB,    14,     2,   254,   294,   305, 0x0,								STR_400B_CURRENTLY_SELECTED_NAME},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1127
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   127,   308,   319, STR_4003_DELETE,		STR_400C_DELETE_THE_CURRENTLY_SELECTED},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1128
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   128,   244,   308,   319, STR_4002_SAVE,			STR_400D_SAVE_THE_CURRENT_GAME_USING},
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1129
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   245,   256,   308,   319, 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
  1130
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1131
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1132
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
static const Widget _save_dialog_scen_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1134
{   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
  1135
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   256,     0,    13, STR_0299_SAVE_SCENARIO, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1136
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   127,    14,    25, STR_SORT_BY_NAME,				STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1137
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   128,   256,    14,    25, STR_SORT_BY_DATE,				STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1138
{     WWT_IMGBTN,  RESIZE_RIGHT,    14,     0,   256,    26,    47, 0x0,										STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1139
{     WWT_IMGBTN,     RESIZE_RB,    14,     0,   256,    48,   291, 0x0,										STR_NULL},
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1140
{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   245,   256,    48,    59, SPR_HOUSE_ICON,					STR_SAVELOAD_HOME_BUTTON},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1141
{          WWT_6,     RESIZE_RB,    14,     2,   243,    50,   290, 0x0,										STR_400A_LIST_OF_DRIVES_DIRECTORIES},
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
  1142
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   245,   256,    60,   291, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1143
{     WWT_IMGBTN,    RESIZE_RTB,    14,     0,   256,   292,   307, 0x0,										STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1144
{     WWT_IMGBTN,    RESIZE_RTB,    14,     2,   254,   294,   305, 0x0,										STR_400B_CURRENTLY_SELECTED_NAME},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1145
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   127,   308,   319, STR_4003_DELETE,				STR_400C_DELETE_THE_CURRENTLY_SELECTED},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1146
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   128,   244,   308,   319, STR_4002_SAVE,					STR_400D_SAVE_THE_CURRENT_GAME_USING},
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1147
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   245,   256,   308,   319, 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
  1148
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1149
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1150
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1151
2261
3f78323707bb (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2255
diff changeset
  1152
// Colors for fios types
3f78323707bb (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2255
diff changeset
  1153
const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5};
3f78323707bb (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2255
diff changeset
  1154
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1155
void BuildFileList(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1156
{
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
  1157
	_fios_path_changed = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1158
	FiosFreeSavegameList();
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1159
	switch (_saveload_mode) {
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1160
		case SLD_NEW_GAME:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1161
		case SLD_LOAD_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1162
		case SLD_SAVE_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1163
			_fios_list = FiosGetScenarioList(&_fios_num, _saveload_mode);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1164
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1165
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1166
		default:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1167
			_fios_list = FiosGetSavegameList(&_fios_num, _saveload_mode);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1168
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1169
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
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
  1172
static void DrawFiosTexts(uint maxw)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1173
{
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
  1174
	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
  1175
	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
  1176
	static uint32 tot = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
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
  1178
	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
  1179
		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
  1180
		_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
  1181
	}
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
  1182
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
  1183
	if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, 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
  1184
	DrawString(2, 37, str, 0);
2103
9266bb2ac29d (svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents: 2100
diff changeset
  1185
	DoDrawStringTruncated(path, 2, 27, 16, maxw);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1186
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1187
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1188
static void MakeSortedSaveGameList(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
{
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1190
	uint sort_start = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1191
	uint sort_end = 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1192
	uint s_amount;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1193
	int i;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1194
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1195
	/*	Directories are always above the files (FIOS_TYPE_DIR)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1196
	 *	Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1197
	 *	Only sort savegames/scenarios, not directories
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1198
	 */
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1199
	for (i = 0; i < _fios_num; i++) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1200
		switch (_fios_list[i].type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1201
			case FIOS_TYPE_DIR:    sort_start++; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1202
			case FIOS_TYPE_PARENT: sort_start++; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1203
			case FIOS_TYPE_DRIVE:  sort_end++;   break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1204
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1205
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1206
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1207
	s_amount = _fios_num - sort_start - sort_end;
1105
b3003b14e45c (svn r1606) Fix some bogus casts
tron
parents: 1095
diff changeset
  1208
	if (s_amount > 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1209
		qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1210
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1211
402
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1212
static void GenerateFileName(void)
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1213
{
635
5a595bc1653f (svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents: 606
diff changeset
  1214
	/* Check if we are not a specatator who wants to generate a name..
5a595bc1653f (svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents: 606
diff changeset
  1215
	    Let's use the name of player #0 for now. */
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1216
	const Player* p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
635
5a595bc1653f (svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents: 606
diff changeset
  1217
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1218
	SetDParam(0, p->name_1);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1219
	SetDParam(1, p->name_2);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1220
	SetDParam(2, _date);
402
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1221
	GetString(_edit_str_buf, STR_4004);
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1222
}
a7dffcd6a4dd (svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents: 390
diff changeset
  1223
1131
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1224
extern void StartupEngines(void);
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1225
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1226
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1227
{
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
  1228
	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
  1229
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
  1230
	switch (e->event) {
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
  1231
	case WE_CREATE: { /* Set up OPENTTD button */
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
  1232
		o_dir.type = FIOS_TYPE_DIRECT;
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
  1233
		switch (_saveload_mode) {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1234
			case SLD_SAVE_GAME:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1235
			case SLD_LOAD_GAME:
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
  1236
				ttd_strlcpy(&o_dir.name[0], _path.save_dir, sizeof(o_dir.name));
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
  1237
				break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1238
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1239
			case SLD_SAVE_SCENARIO:
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1240
			case SLD_LOAD_SCENARIO:
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
  1241
				ttd_strlcpy(&o_dir.name[0], _path.scenario_dir, sizeof(o_dir.name));
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
  1242
				break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1243
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
  1244
			default:
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
  1245
				ttd_strlcpy(&o_dir.name[0], _path.personal_dir, sizeof(o_dir.name));
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
  1246
		}
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
  1247
		break;
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
  1248
		}
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
  1249
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1250
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
		int y,pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1252
		const FiosItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1253
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1254
		SetVScrollCount(w, _fios_num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1255
		DrawWindowWidgets(w);
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
  1256
		DrawFiosTexts(w->width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1257
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1258
		if (_savegame_sort_dirty) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1259
			_savegame_sort_dirty = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1260
			MakeSortedSaveGameList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1261
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1262
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1263
		GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7);
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1264
		DoDrawString(
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1265
			_savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW,
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1266
			_savegame_sort_order & SORT_BY_NAME ? w->widget[2].right - 9 : w->widget[3].right - 9,
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1267
			15, 16
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1268
		);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1269
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1270
		y = w->widget[7].top + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1271
		pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1272
		while (pos < _fios_num) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
			item = _fios_list + pos;
2103
9266bb2ac29d (svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents: 2100
diff changeset
  1274
			DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1275
			pos++;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1276
			y += 10;
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1277
			if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1278
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1279
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1280
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
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
  1281
			DrawEditBox(w, &WP(w,querystr_d), 10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1282
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1283
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1284
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1285
	case WE_CLICK:
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
  1286
		switch (e->click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1287
		case 2: /* Sort save names by name */
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1288
			_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1289
				SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1290
			_savegame_sort_dirty = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1291
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1292
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1293
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1294
		case 3: /* Sort save names by date */
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1295
			_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1296
				SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1297
			_savegame_sort_dirty = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1298
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1299
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1300
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1301
		case 6: /* OpenTTD 'button', jumps to OpenTTD directory */
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1302
			FiosBrowseTo(&o_dir);
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1303
			SetWindowDirty(w);
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1304
			BuildFileList();
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1305
			break;
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1306
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1307
		case 7: { /* Click the listbox */
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1308
			int y = (e->click.pt.y - w->widget[e->click.widget].top - 1) / 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1309
			char *name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1310
			const FiosItem *file;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1311
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1312
			if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
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
			file = _fios_list + y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1315
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1316
			name = FiosBrowseTo(file);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1317
			if (name != NULL) {
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
  1318
				if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
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
  1319
					_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
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
  1320
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1321
					SetFiosType(file->type);
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
  1322
					ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
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
  1323
					ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
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
  1324
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1325
					DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1326
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1327
					// SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox
9948
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1328
					ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
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
  1329
					UpdateTextBufferSize(&WP(w, querystr_d).text);
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
  1330
					InvalidateWidget(w, 10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1331
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1332
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1333
				// Changed directory, need repaint.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1334
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1335
				BuildFileList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1336
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1337
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1338
		}
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
  1339
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
  1340
		case 11: case 12: /* Delete, Save game */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1341
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1342
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1343
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1344
	case WE_MOUSELOOP:
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
  1345
		HandleEditBox(w, &WP(w, querystr_d), 10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1346
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1347
	case WE_KEYPRESS:
2165
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1348
		if (e->keypress.keycode == WKC_ESC) {
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1349
			DeleteWindow(w);
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1350
			return;
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1351
		}
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1352
5729e4207de5 (svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents: 2163
diff changeset
  1353
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
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
  1354
			if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) /* Press Enter */
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
  1355
					HandleButtonClick(w, 12);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1356
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1357
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
	case WE_TIMEOUT:
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
  1359
		if (HASBIT(w->click_state, 11)) { /* Delete button clicked */
2255
ddcaf9e333ff (svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents: 2201
diff changeset
  1360
			if (!FiosDelete(WP(w,querystr_d).text.buf)) {
ddcaf9e333ff (svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents: 2201
diff changeset
  1361
				ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
9948
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1362
			} else {
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1363
				BuildFileList();
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1364
				/* Reset file name to current date on successfull delete */
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1365
				if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
2255
ddcaf9e333ff (svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents: 2201
diff changeset
  1366
			}
9948
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1367
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1368
			UpdateTextBufferSize(&WP(w, querystr_d).text);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1369
			SetWindowDirty(w);
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
  1370
		} else if (HASBIT(w->click_state, 12)) { /* Save button clicked */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1371
			_switch_mode = SM_SAVE;
9948
877dccfeb22e (svn r4018) -Backport from trunk (4001:4002):
celestar
parents: 2898
diff changeset
  1372
			FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf, sizeof(_file_to_saveload.name));
1131
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1373
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1374
			/* In the editor set up the vehicle engines correctly (date might have changed) */
21a18a6c1b4b (svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents: 1126
diff changeset
  1375
			if (_game_mode == GM_EDITOR) StartupEngines();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1376
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1377
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1378
	case WE_DESTROY:
1274
1605774b5589 (svn r1778) - Fix: [ 1115200 ] In the main menu, when starting a new game while the load game dialog is open, openttd asserts.
matthijs
parents: 1176
diff changeset
  1379
		// pause is only used in single-player, non-editor mode, non menu mode
1605774b5589 (svn r1778) - Fix: [ 1115200 ] In the main menu, when starting a new game while the load game dialog is open, openttd asserts.
matthijs
parents: 1176
diff changeset
  1380
		if(!_networking && (_game_mode != GM_EDITOR) && (_game_mode != GM_MENU))
278
950c3ac6e649 (svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents: 258
diff changeset
  1381
			DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1382
		FiosFreeSavegameList();
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
  1383
		CLRBIT(_no_scroll, SCROLL_SAVE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1384
		break;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1385
	case WE_RESIZE: {
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1386
		/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1387
		uint diff = e->sizing.diff.x / 2;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1388
		w->widget[2].right += diff;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1389
		w->widget[3].left  += diff;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1390
		w->widget[3].right += e->sizing.diff.x;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1391
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
  1392
		/* Same for widget 11 and 12 in save-dialog */
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1393
		if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
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
  1394
			w->widget[11].right += diff;
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
  1395
			w->widget[12].left  += diff;
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
  1396
			w->widget[12].right += e->sizing.diff.x;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1397
		}
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1398
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1399
		w->vscroll.cap += e->sizing.diff.y / 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1400
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1401
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1402
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1403
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1404
static const WindowDesc _load_dialog_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1405
	WDP_CENTER, WDP_CENTER, 257, 294,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1406
	WC_SAVELOAD,0,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1407
	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
  1408
	_load_dialog_1_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1410
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1412
static const WindowDesc _load_dialog_scen_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
	WDP_CENTER, WDP_CENTER, 257, 294,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1414
	WC_SAVELOAD,0,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1415
	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
  1416
	_load_dialog_2_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1417
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1418
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1419
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1420
static const WindowDesc _save_dialog_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1421
	WDP_CENTER, WDP_CENTER, 257, 320,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1422
	WC_SAVELOAD,0,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1423
	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
  1424
	_save_dialog_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1425
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1426
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1427
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1428
static const WindowDesc _save_dialog_scen_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1429
	WDP_CENTER, WDP_CENTER, 257, 320,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1430
	WC_SAVELOAD,0,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1431
	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
  1432
	_save_dialog_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1433
	SaveLoadDlgWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1434
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1435
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1436
static const WindowDesc * const _saveload_dialogs[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1437
	&_load_dialog_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1438
	&_load_dialog_scen_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1439
	&_save_dialog_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1440
	&_save_dialog_scen_desc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1441
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1442
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1443
void ShowSaveLoadDialog(int mode)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1444
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1445
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1446
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1447
	SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1448
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1449
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1450
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1451
	_saveload_mode = 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
  1452
	SETBIT(_no_scroll, SCROLL_SAVE);
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
  1453
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
  1454
	switch (mode) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1455
		case SLD_SAVE_GAME:     GenerateFileName(); break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1456
		case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); 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
  1457
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1458
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1459
	w = AllocateWindowDesc(_saveload_dialogs[mode]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1460
	w->vscroll.cap = 24;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1461
	w->resize.step_width = 2;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1462
	w->resize.step_height = 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1463
	w->resize.height = w->height - 14 * 10; // Minimum of 10 items
2750
f003e561f4b9 (svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents: 2748
diff changeset
  1464
	SETBIT(w->click_state, 7);
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
  1465
	WP(w,querystr_d).text.caret = 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
  1466
	WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf) - 1;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1467
	WP(w,querystr_d).text.maxwidth = 240;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1468
	WP(w,querystr_d).text.buf = _edit_str_buf;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1386
diff changeset
  1469
	UpdateTextBufferSize(&WP(w, querystr_d).text);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1470
1274
1605774b5589 (svn r1778) - Fix: [ 1115200 ] In the main menu, when starting a new game while the load game dialog is open, openttd asserts.
matthijs
parents: 1176
diff changeset
  1471
	// pause is only used in single-player, non-editor mode, non-menu mode. It
1605774b5589 (svn r1778) - Fix: [ 1115200 ] In the main menu, when starting a new game while the load game dialog is open, openttd asserts.
matthijs
parents: 1176
diff changeset
  1472
	// will be unpaused in the WE_DESTROY event handler.
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1473
	if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
278
950c3ac6e649 (svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents: 258
diff changeset
  1474
		DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1475
	}
278
950c3ac6e649 (svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents: 258
diff changeset
  1476
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1477
	BuildFileList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1478
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1479
	ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1480
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1481
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1482
void RedrawAutosave(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1483
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1484
	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1485
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1486
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1487
static const Widget _select_scenario_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2703
diff changeset
  1488
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     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
  1489
{    WWT_CAPTION,  RESIZE_RIGHT,     7,    11,   256,     0,    13, STR_400E_SELECT_NEW_GAME_TYPE, STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1490
{     WWT_IMGBTN,  RESIZE_RIGHT,     7,     0,   256,    14,    25, 0x0,								STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1491
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     7,     0,   127,    14,    25, STR_SORT_BY_NAME,		STR_SORT_ORDER_TIP},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1492
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     7,   128,   256,    14,    25, STR_SORT_BY_DATE,		STR_SORT_ORDER_TIP},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1493
{     WWT_IMGBTN,     RESIZE_RB,     7,     0,   244,    26,   319, 0x0,								STR_NULL},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1494
{          WWT_6,     RESIZE_RB,     7,     2,   243,    28,   317, 0x0,								STR_400F_SELECT_SCENARIO_GREEN_PRE},
893
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1495
{  WWT_SCROLLBAR,    RESIZE_LRB,     7,   245,   256,    26,   307, 0x0,								STR_0190_SCROLL_BAR_SCROLLS_LIST},
d9e69e5060ba (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 888
diff changeset
  1496
{  WWT_RESIZEBOX,   RESIZE_LRTB,     7,   245,   256,   308,   319, 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
  1497
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1498
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1499
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1500
static void SelectScenarioWndProc(Window* w, WindowEvent* e)
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1501
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1502
	const int list_start = 45;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1503
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1504
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1505
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1506
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1507
		int y,pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1508
		const FiosItem *item;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1509
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1510
		if (_savegame_sort_dirty) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1511
			_savegame_sort_dirty = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1512
			MakeSortedSaveGameList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1513
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1514
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1515
		SetVScrollCount(w, _fios_num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1516
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1517
		DrawWindowWidgets(w);
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1518
		DoDrawString(
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1519
			_savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW,
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1520
			_savegame_sort_order & SORT_BY_NAME ? w->widget[3].right - 9 : w->widget[4].right - 9,
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1521
			15, 16
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1522
		);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1523
		DrawString(4, 32, STR_4010_GENERATE_RANDOM_NEW_GAME, 9);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1524
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1525
		y = list_start;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1526
		pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1527
		while (pos < _fios_num) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1528
			item = _fios_list + pos;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1529
			DoDrawString(item->title, 4, y, _fios_colors[item->type]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1530
			pos++;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1531
			y += 10;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1532
			if (y >= w->vscroll.cap * 10 + list_start) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1533
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1534
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1535
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1536
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1537
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1538
		switch(e->click.widget) {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1539
		case 3: /* Sort scenario names by name */
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1540
			_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1541
				SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1542
			_savegame_sort_dirty = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1543
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1544
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1545
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1546
		case 4: /* Sort scenario names by date */
2526
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1547
			_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
cae4842086a9 (svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents: 2498
diff changeset
  1548
				SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1549
			_savegame_sort_dirty = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1550
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1551
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1552
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1553
		case 6: /* Click the listbox */
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1784
diff changeset
  1554
			if (e->click.pt.y < list_start)
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1784
diff changeset
  1555
				GenRandomNewGame(Random(), InteractiveRandom());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1556
			else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1557
				char *name;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1558
				int y = (e->click.pt.y - list_start) / 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1559
				const FiosItem *file;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1560
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1561
				if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1562
					return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1564
				file = _fios_list + y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1565
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1566
				name = FiosBrowseTo(file);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1567
				if (name != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1568
					SetFiosType(file->type);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1569
					strcpy(_file_to_saveload.name, name);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1570
					DeleteWindow(w);
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1794
diff changeset
  1571
					StartScenarioEditor(Random(), InteractiveRandom());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1572
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
			break;
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
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1577
		break;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1578
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1579
	case WE_RESIZE: {
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1580
		/* Widget 3 and 4 have to go with halve speed, make it so obiwan */
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1581
		uint diff = e->sizing.diff.x / 2;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1582
		w->widget[3].right += diff;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1583
		w->widget[4].left  += diff;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1584
		w->widget[4].right += e->sizing.diff.x;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1585
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1586
		w->vscroll.cap += e->sizing.diff.y / 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1587
		} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1588
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1589
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1590
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1591
void SetFiosType(const byte fiostype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1592
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1593
	switch (fiostype) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1594
		case FIOS_TYPE_FILE:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1595
		case FIOS_TYPE_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1596
			_file_to_saveload.mode = SL_LOAD;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1597
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1598
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1599
		case FIOS_TYPE_OLDFILE:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1600
		case FIOS_TYPE_OLD_SCENARIO:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1601
			_file_to_saveload.mode = SL_OLD_LOAD;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1602
			break;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1603
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1604
		default:
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1605
			_file_to_saveload.mode = SL_INVALID;
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1606
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1607
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1608
}
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
static const WindowDesc _select_scenario_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1611
	WDP_CENTER, WDP_CENTER, 257, 320,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1612
	WC_SAVELOAD,0,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1613
	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
  1614
	_select_scenario_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1615
	SelectScenarioWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1616
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1617
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1618
void AskForNewGameToStart(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1619
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1620
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1621
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1622
	DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1623
	DeleteWindowById(WC_SAVELOAD, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1624
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1625
	_saveload_mode = SLD_NEW_GAME;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1626
	BuildFileList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1627
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1628
	w = AllocateWindowDesc(&_select_scenario_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1629
	w->vscroll.cap = 27;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1630
	w->resize.step_width = 2;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1631
	w->resize.step_height = 10;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1632
	w->resize.height = w->height - 10 * 17; // Minimum of 10 in the list
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1633
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1634
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 402
diff changeset
  1635
static int32 ClickMoneyCheat(int32 p1, int32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1636
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1637
		DoCommandP(0, -10000000, 0, NULL, CMD_MONEY_CHEAT);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1638
		return true;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1641
// p1 player to set to, p2 is -1 or +1 (down/up)
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 402
diff changeset
  1642
static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1643
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1644
	while (p1 >= 0 && p1 < MAX_PLAYERS) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1645
		if (_players[p1].is_active) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1646
			_local_player = p1;
138
6ab4d97d1034 (svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents: 108
diff changeset
  1647
			MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1648
			return _local_player;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1649
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1650
		p1 += p2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1651
	}
155
81e9878f3678 (svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents: 147
diff changeset
  1652
81e9878f3678 (svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents: 147
diff changeset
  1653
	return _local_player;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1654
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1655
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1656
// p1 -1 or +1 (down/up)
1095
90220990fd7c (svn r1596) Add some more statics
tron
parents: 1093
diff changeset
  1657
static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1658
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1659
	if (p1 == -1) p1 = 3;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1660
	if (p1 ==  4) p1 = 0;
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1661
	_opt.landscape = p1;
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1662
	GfxLoadSprites();
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1663
	MarkWholeScreenDirty();
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1664
	return _opt.landscape;
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1665
}
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1666
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1667
extern void EnginesMonthlyLoop(void);
108
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1668
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1669
// p2 1 (increase) or -1 (decrease)
1095
90220990fd7c (svn r1596) Add some more statics
tron
parents: 1093
diff changeset
  1670
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
108
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1671
{
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1672
	YearMonthDay ymd;
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1673
	ConvertDayToYMD(&ymd, _date);
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1674
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1675
	if ((ymd.year == 0 && p2 == -1) || (ymd.year == 170 && p2 == 1)) return _cur_year;
108
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1676
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1677
	SetDate(ConvertYMDToDay(_cur_year + p2, ymd.month, ymd.day));
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1678
	EnginesMonthlyLoop();
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1679
	SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1680
	return _cur_year;
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1681
}
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1682
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1683
typedef int32 CheckButtonClick(int32, int32);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1684
1345
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1685
typedef enum ce_type {
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1686
	CE_BOOL = 0,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1687
	CE_UINT8 = 1,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1688
	CE_INT16 = 2,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1689
	CE_UINT16 = 3,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1690
	CE_INT32 = 4,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1691
	CE_BYTE = 5,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1692
	CE_CLICK = 6,
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1693
} ce_type;
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1694
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1695
typedef struct CheatEntry {
1345
5cb0e0eda22d (svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents: 1344
diff changeset
  1696
	ce_type type;    // type of selector
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1697
	byte flags;		// selector flags
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1698
	StringID str; // string with descriptive text
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1699
	void *variable; // pointer to the variable
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1700
	bool *been_used; // has this cheat been used before?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1701
	CheckButtonClick *click_proc; // procedure
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1702
	int16 min,max; // range for spinbox setting
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1703
	uint16 step;   // step for spinbox
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1704
} CheatEntry;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1705
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1706
static int32 ReadCE(const CheatEntry* ce)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1707
{
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1708
	switch (ce->type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1709
		case CE_BOOL:   return *(bool*  )ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1710
		case CE_UINT8:  return *(uint8* )ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1711
		case CE_INT16:  return *(int16* )ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1712
		case CE_UINT16: return *(uint16*)ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1713
		case CE_INT32:  return *(int32* )ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1714
		case CE_BYTE:   return *(byte*  )ce->variable;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1715
		case CE_CLICK:  return 0;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1716
		default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1717
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1718
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1719
	/* useless, but avoids compiler warning this way */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1720
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1721
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1722
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1723
static void WriteCE(const CheatEntry *ce, int32 val)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1724
{
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1725
	switch (ce->type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1726
		case CE_BOOL:   *(bool*  )ce->variable = (bool  )val; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1727
		case CE_BYTE:   *(byte*  )ce->variable = (byte  )val; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1728
		case CE_UINT8:  *(uint8* )ce->variable = (uint8 )val; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1729
		case CE_INT16:  *(int16* )ce->variable = (int16 )val; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1730
		case CE_UINT16: *(uint16*)ce->variable = (uint16)val; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1731
		case CE_INT32:  *(int32* )ce->variable = val;         break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1732
		case CE_CLICK: break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
  1733
		default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1734
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1735
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1736
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1737
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1738
static const CheatEntry _cheats_ui[] = {
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1739
	{CE_CLICK, 0, STR_CHEAT_MONEY, 					&_cheats.money.value, 					&_cheats.money.been_used, 					&ClickMoneyCheat,					0, 0, 0},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1740
	{CE_UINT8, 0, STR_CHEAT_CHANGE_PLAYER, 	&_local_player, 								&_cheats.switch_player.been_used,		&ClickChangePlayerCheat,	0, 11, 1},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1741
	{CE_BOOL, 0, STR_CHEAT_EXTRA_DYNAMITE,	&_cheats.magic_bulldozer.value,	&_cheats.magic_bulldozer.been_used, NULL,											0, 0, 0},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1742
	{CE_BOOL, 0, STR_CHEAT_CROSSINGTUNNELS,	&_cheats.crossing_tunnels.value,&_cheats.crossing_tunnels.been_used,NULL,											0, 0, 0},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1743
	{CE_BOOL, 0, STR_CHEAT_BUILD_IN_PAUSE,	&_cheats.build_in_pause.value,	&_cheats.build_in_pause.been_used,	NULL,											0, 0, 0},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1744
	{CE_BOOL, 0, STR_CHEAT_NO_JETCRASH,			&_cheats.no_jetcrash.value,			&_cheats.no_jetcrash.been_used,			NULL,											0, 0, 0},
1176
46d14419c1dd (svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents: 1131
diff changeset
  1745
	{CE_BOOL, 0, STR_CHEAT_SETUP_PROD,			&_cheats.setup_prod.value,			&_cheats.setup_prod.been_used,			NULL,											0, 0, 0},
179
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1746
	{CE_UINT8, 0, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, 								&_cheats.switch_climate.been_used,	&ClickChangeClimateCheat,-1, 4, 1},
003096efeb9d (svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents: 176
diff changeset
  1747
	{CE_UINT8, 0, STR_CHEAT_CHANGE_DATE,		&_cur_year,											&_cheats.change_date.been_used,			&ClickChangeDateCheat,	 -1, 1, 1},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1748
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1749
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1750
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1751
static const Widget _cheat_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1752
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,		STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
  1753
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   399,     0,    13, STR_CHEATS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
1176
46d14419c1dd (svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents: 1131
diff changeset
  1754
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   399,    14,   159, 0x0,					STR_NULL},
46d14419c1dd (svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents: 1131
diff changeset
  1755
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   399,    14,   159, 0x0,					STR_CHEATS_TIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 172
diff changeset
  1756
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1757
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1758
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1759
extern void DrawPlayerIcon(int p, int x, int y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1760
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1761
static void CheatsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1762
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1763
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1764
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1765
		int clk = WP(w,def_d).data_1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1766
		int x, y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1767
		int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1768
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1769
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1770
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1771
		DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, 350);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1772
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1773
		x = 0;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1774
		y = 45;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1775
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1776
		for (i = 0; i != lengthof(_cheats_ui); i++) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1777
			const CheatEntry* ce = &_cheats_ui[i];
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1778
2535
ed8b9592dc64 (svn r3064) Replace some numbers by sprite names
tron
parents: 2526
diff changeset
  1779
			DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, x + 5, y + 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1780
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1781
			if (ce->type == CE_BOOL) {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1782
				DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, (*(bool*)ce->variable) ? 6 : 4, (*(bool*)ce->variable) ? FR_LOWERED : 0);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1783
				SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1784
			}	else if (ce->type == CE_CLICK) {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1785
				DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, 0, (WP(w,def_d).data_1 == i * 2 + 1) ? FR_LOWERED : 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1786
				if (i == 0) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1787
					SetDParam64(0, 10000000);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1788
				} else {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1789
					SetDParam(0, false);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1790
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1791
			} else {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1792
				int32 val;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1793
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1794
				DrawFrameRect(x + 20, y + 1, x + 20 + 9, y + 9, 3, clk == i * 2 + 1 ? FR_LOWERED : 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1795
				DrawFrameRect(x + 30, y + 1, x + 30 + 9, y + 9, 3, clk == i * 2 + 2 ? FR_LOWERED : 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1796
				DrawStringCentered(x + 25, y + 1, STR_6819, 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1797
				DrawStringCentered(x + 35, y + 1, STR_681A, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1798
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1799
				val = ReadCE(ce);
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1800
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1801
				// set correct string for switch climate cheat
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1802
				if (ce->str == STR_CHEAT_SWITCH_CLIMATE) val += STR_TEMPERATE_LANDSCAPE;
100
8e87945f6bcb (svn r101) New cheat: switch climate
dominik
parents: 74
diff changeset
  1803
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1804
				SetDParam(0, val);
108
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1805
8e2e584a9500 (svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents: 104
diff changeset
  1806
				// display date for change date cheat
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1807
				if (ce->str == STR_CHEAT_CHANGE_DATE) SetDParam(0, _date);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1808
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1809
				// draw colored flag for change player cheat
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1810
				if (ce->str == STR_CHEAT_CHANGE_PLAYER) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1811
					DrawPlayerIcon(_current_player, 156, y + 2);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1812
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1813
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1814
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1815
			DrawString(50, y + 1, ce->str, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1816
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1817
			y += 12;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1818
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1819
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1820
	}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1821
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1822
	case WE_CLICK: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1823
			const CheatEntry *ce;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1824
			uint btn = (e->click.pt.y - 46) / 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1825
			int32 val, oval;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1826
			uint x = e->click.pt.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1827
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1828
			// not clicking a button?
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1829
			if (!IS_INT_INSIDE(x, 20, 40) || btn >= lengthof(_cheats_ui)) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1830
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1831
			ce = &_cheats_ui[btn];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1832
			oval = val = ReadCE(ce);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1833
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1834
			*ce->been_used = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1835
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1836
			switch (ce->type) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1837
				case CE_BOOL:	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1838
					val ^= 1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1839
					if (ce->click_proc != NULL) ce->click_proc(val, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1840
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1841
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1842
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1843
				case CE_CLICK:	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1844
					ce->click_proc(val, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1845
					WP(w,def_d).data_1 = btn * 2 + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1846
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1847
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1848
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1849
				default:	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1850
					if (x >= 30) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1851
						//increase
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1852
						val += ce->step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1853
						if (val > ce->max) val = ce->max;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1854
					} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1855
						// decrease
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1856
						val -= ce->step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1857
						if (val < ce->min) val = ce->min;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1858
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1859
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1860
					// take whatever the function returns
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1861
					val = ce->click_proc(val, (x >= 30) ? 1 : -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1862
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1863
					if (val != oval) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1864
						WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1865
					}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1866
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1867
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1868
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1869
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1870
			if (val != oval) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1871
				WriteCE(ce, val);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1872
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1873
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1874
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1875
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1876
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1877
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1878
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1879
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1880
	case WE_TIMEOUT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1881
		WP(w,def_d).data_1 = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1882
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1883
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1884
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1885
}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1886
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1887
static const WindowDesc _cheats_desc = {
1176
46d14419c1dd (svn r1678) Added cheat option for setting production of raw-material product industries in game
miham
parents: 1131
diff changeset
  1888
	240, 22, 400, 160,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1889
	WC_CHEATS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1890
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1891
	_cheat_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1892
	CheatsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1893
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1894
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1895
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1009
diff changeset
  1896
void ShowCheatWindow(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1897
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1898
	Window *w;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1899
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1900
	DeleteWindowById(WC_CHEATS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1901
	w = AllocateWindowDesc(&_cheats_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1902
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2535
diff changeset
  1903
	if (w != NULL) SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1904
}