author | Darkvater |
Fri, 28 Oct 2005 00:09:59 +0000 | |
changeset 2559 | 08e648022cb0 |
parent 2549 | f1d3b383d557 |
child 2630 | 35249d2ded3e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 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 | 14 |
#include "window.h" |
15 |
#include "gui.h" |
|
16 |
#include "viewport.h" |
|
17 |
#include "gfx.h" |
|
18 |
#include "station.h" |
|
19 |
#include "command.h" |
|
20 |
#include "player.h" |
|
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 | 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 | 32 |
bool _query_string_active; |
33 |
||
34 |
typedef struct LandInfoData { |
|
35 |
Town *town; |
|
36 |
int32 costclear; |
|
37 |
AcceptedCargo ac; |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
38 |
TileIndex tile; |
0 | 39 |
TileDesc td; |
40 |
} LandInfoData; |
|
41 |
||
42 |
static void LandInfoWndProc(Window *w, WindowEvent *e) |
|
43 |
{ |
|
44 |
LandInfoData *lid; |
|
45 |
StringID str; |
|
46 |
||
47 |
if (e->event == WE_PAINT) { |
|
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
48 |
int i; |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
49 |
|
0 | 50 |
DrawWindowWidgets(w); |
51 |
||
52 |
lid = WP(w,void_d).data; |
|
53 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
54 |
SetDParam(0, lid->td.dparam[0]); |
0 | 55 |
DrawStringCentered(140, 16, lid->td.str, 13); |
56 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
57 |
SetDParam(0, STR_01A6_N_A); |
0 | 58 |
if (lid->td.owner != OWNER_NONE && lid->td.owner != OWNER_WATER) |
59 |
GetNameOfOwner(lid->td.owner, lid->tile); |
|
60 |
DrawStringCentered(140, 27, STR_01A7_OWNER, 0); |
|
61 |
||
62 |
str = STR_01A4_COST_TO_CLEAR_N_A; |
|
63 |
if (lid->costclear != CMD_ERROR) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
64 |
SetDParam(0, lid->costclear); |
0 | 65 |
str = STR_01A5_COST_TO_CLEAR; |
66 |
} |
|
67 |
DrawStringCentered(140, 38, str, 0); |
|
68 |
||
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
SetDParam(2, STR_SPEC_USERSTRING); |
0 | 73 |
DrawStringCentered(140, 49, STR_LANDINFO_COORDS, 0); |
74 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
75 |
SetDParam(0, STR_01A9_NONE); |
0 | 76 |
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
|
77 |
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
|
78 |
SetDParam(1, lid->town->index); |
0 | 79 |
} |
80 |
DrawStringCentered(140,60, STR_01A8_LOCAL_AUTHORITY, 0); |
|
81 |
||
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
82 |
{ |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
bool found = false; |
0 | 86 |
|
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
// Add a comma between each item. |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
90 |
if (found) { *p++ = ','; *p++ = ' '; } |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
91 |
found = true; |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
92 |
|
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
93 |
// 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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
} else { |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
100 |
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
|
101 |
} |
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
102 |
} |
0 | 103 |
} |
104 |
||
2063
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
105 |
if (found) |
95259a31ceb5
(svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde
parents:
2049
diff
changeset
|
106 |
DrawStringMultiCenter(140, 76, BindCString(buf), 276); |
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 | 113 |
} |
114 |
} |
|
115 |
||
116 |
static const Widget _land_info_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
117 |
{ WWT_TEXTBTN, 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
|
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 | 121 |
}; |
122 |
||
123 |
static const WindowDesc _land_info_desc = { |
|
124 |
-1, -1, 280, 93, |
|
125 |
WC_LAND_INFO,0, |
|
126 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
127 |
_land_info_widgets, |
|
128 |
LandInfoWndProc |
|
129 |
}; |
|
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 | 132 |
{ |
133 |
Player *p; |
|
134 |
static LandInfoData lid; |
|
135 |
Window *w; |
|
136 |
int64 old_money; |
|
137 |
||
138 |
DeleteWindowById(WC_LAND_INFO, 0); |
|
139 |
||
140 |
w = AllocateWindowDesc(&_land_info_desc); |
|
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 | 143 |
lid.tile = tile; |
144 |
lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority); |
|
145 |
||
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
146 |
if (_local_player >= MAX_PLAYERS) |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
147 |
p = GetPlayer(0); |
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
148 |
else |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
149 |
p = GetPlayer(_local_player); |
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
150 |
|
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
151 |
old_money = p->money64; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
152 |
p->money64 = p->player_money = 0x7fffffff; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
153 |
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
|
154 |
p->money64 = old_money; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
155 |
UpdatePlayerMoney32(p); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
156 |
|
71
1b8e15a10515
(svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents:
70
diff
changeset
|
157 |
// 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
|
158 |
lid.td.build_date = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
159 |
|
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
160 |
GetAcceptedCargo(tile, lid.ac); |
0 | 161 |
GetTileDesc(tile, &lid.td); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
162 |
|
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
163 |
#if defined(_DEBUG) |
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
|
164 |
DEBUG(misc, 0) ("TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); |
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
138
diff
changeset
|
165 |
DEBUG(misc, 0) ("TILE: %d ", tile); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1980
diff
changeset
|
166 |
DEBUG(misc, 0) ("_type_height = %#x", _m[tile].type_height); |
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2340
diff
changeset
|
167 |
DEBUG(misc, 0) ("m1 = %#x", _m[tile].m1); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1980
diff
changeset
|
168 |
DEBUG(misc, 0) ("m2 = %#x", _m[tile].m2); |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1980
diff
changeset
|
169 |
DEBUG(misc, 0) ("m3 = %#x", _m[tile].m3); |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1980
diff
changeset
|
170 |
DEBUG(misc, 0) ("m4 = %#x", _m[tile].m4); |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1980
diff
changeset
|
171 |
DEBUG(misc, 0) ("m5 = %#x", _m[tile].m5); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
172 |
#endif |
0 | 173 |
} |
174 |
||
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
|
175 |
void PlaceLandBlockInfo(void) |
0 | 176 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
177 |
if (_cursor.sprite == SPR_CURSOR_QUERY) { |
0 | 178 |
ResetObjectToPlace(); |
179 |
} else { |
|
180 |
_place_proc = Place_LandInfo; |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
181 |
SetObjectToPlace(SPR_CURSOR_QUERY, 1, 1, 0); |
0 | 182 |
} |
183 |
} |
|
184 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
185 |
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
|
186 |
/************************************************************************* |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
187 |
* 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
|
188 |
"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
|
189 |
"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
|
190 |
"", |
1124 | 191 |
"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
|
192 |
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder", |
1826
d123cb6b11dc
(svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents:
1821
diff
changeset
|
193 |
" Matthijs Kooijman (blathijs) - Pathfinder-god", |
1125 | 194 |
" Victor Fischer (Celestar) - Programming everywhere you need him to", |
2134 | 195 |
" Tamás Faragó (Darkvater) - Lead coder", |
1124 | 196 |
" 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
|
197 |
" Owen Rudge (orudge) - Forum- and masterserver host, OS/2 port", |
1126 | 198 |
" Christoph Mallon (Tron) - Programmer, code correctness police", |
1124 | 199 |
" Patric Stout (TrueLight) - Coder, network guru, SVN- and website host", |
1125 | 200 |
"", |
201 |
"Retired Developers:", |
|
202 |
" 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
|
203 |
" 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
|
204 |
" 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
|
205 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
206 |
"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
|
207 |
" 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
|
208 |
" Marcin Grzegorczyk - For his documentation of TTD internals", |
1577 | 209 |
" 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
|
210 |
" 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
|
211 |
" Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with (and PBS)", |
1124 | 212 |
" Cian Duffy (MYOB) - BeOS port / manual writing", |
213 |
" 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
|
214 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
215 |
" 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
|
216 |
" 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
|
217 |
" 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
|
218 |
" 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
|
219 |
" 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
|
220 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
221 |
"", |
1124 | 222 |
"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
|
223 |
" 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
|
224 |
}; |
0 | 225 |
|
226 |
static void AboutWindowProc(Window *w, WindowEvent *e) |
|
227 |
{ |
|
228 |
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
|
229 |
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
|
230 |
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
|
231 |
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
|
232 |
break; |
0 | 233 |
case WE_PAINT: { |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
234 |
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
|
235 |
int y = WP(w, scroller_d).height; |
0 | 236 |
DrawWindowWidgets(w); |
237 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
238 |
// Show original copyright and revision version |
1125 | 239 |
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0); |
240 |
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
|
241 |
|
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
242 |
// 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
|
243 |
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
|
244 |
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
|
245 |
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
|
246 |
} |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
247 |
y += 10; |
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 |
|
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
250 |
// 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
|
251 |
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
|
252 |
|
2134 | 253 |
DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", 16); |
254 |
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
|
255 |
} break; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
SetWindowDirty(w); |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
260 |
} |
0 | 261 |
break; |
262 |
} |
|
263 |
} |
|
264 |
||
265 |
static const Widget _about_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
266 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
1125 | 267 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
268 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
|
269 |
{ 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
|
270 |
{ WIDGETS_END}, |
0 | 271 |
}; |
272 |
||
273 |
static const WindowDesc _about_desc = { |
|
1125 | 274 |
WDP_CENTER, WDP_CENTER, 420, 272, |
0 | 275 |
WC_GAME_OPTIONS,0, |
276 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
277 |
_about_widgets, |
|
278 |
AboutWindowProc |
|
279 |
}; |
|
280 |
||
281 |
||
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
|
282 |
void ShowAboutWindow(void) |
0 | 283 |
{ |
284 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
285 |
AllocateWindowDesc(&_about_desc); |
|
286 |
} |
|
287 |
||
288 |
static int _tree_to_plant; |
|
289 |
||
290 |
static const uint32 _tree_sprites[] = { |
|
291 |
0x655,0x663,0x678,0x62B,0x647,0x639,0x64E,0x632,0x67F,0x68D,0x69B,0x6A9, |
|
292 |
0x6AF,0x6D2,0x6D9,0x6C4,0x6CB,0x6B6,0x6BD,0x6E0, |
|
293 |
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
|
294 |
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 | 295 |
}; |
296 |
||
297 |
static void BuildTreesWndProc(Window *w, WindowEvent *e) |
|
298 |
{ |
|
299 |
switch(e->event) { |
|
300 |
case WE_PAINT: { |
|
301 |
int x,y; |
|
302 |
int i, count; |
|
303 |
||
304 |
DrawWindowWidgets(w); |
|
305 |
||
306 |
WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape]; |
|
307 |
WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape]; |
|
308 |
||
309 |
x = 18; |
|
310 |
y = 54; |
|
311 |
do { |
|
312 |
DrawSprite(_tree_sprites[i], x, y); |
|
313 |
x += 35; |
|
314 |
if (!(++i & 3)) { |
|
315 |
x -= 35*4; |
|
316 |
y += 47; |
|
317 |
} |
|
318 |
} while (--count); |
|
319 |
} break; |
|
320 |
||
321 |
case WE_CLICK: { |
|
322 |
int wid; |
|
323 |
||
324 |
switch(wid=e->click.widget) { |
|
325 |
case 0: |
|
326 |
ResetObjectToPlace(); |
|
327 |
return; |
|
328 |
case 3: case 4: case 5: case 6: |
|
329 |
case 7: case 8: case 9: case 10: |
|
330 |
case 11:case 12: case 13: case 14: |
|
331 |
if ( (uint)(wid-3) >= (uint)WP(w,tree_d).count) |
|
332 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
333 |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
334 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL)) |
0 | 335 |
_tree_to_plant = WP(w,tree_d).base + wid - 3; |
336 |
break; |
|
337 |
||
338 |
case 15: // tree of random type. |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
339 |
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, 1, NULL)) |
0 | 340 |
_tree_to_plant = -1; |
341 |
break; |
|
342 |
||
343 |
case 16: /* place trees randomly over the landscape*/ |
|
344 |
w->click_state |= 1 << 16; |
|
345 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
541 | 346 |
SndPlayFx(SND_15_BEEP); |
0 | 347 |
PlaceTreesRandomly(); |
348 |
MarkWholeScreenDirty(); |
|
349 |
break; |
|
350 |
} |
|
351 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
352 |
|
0 | 353 |
case WE_PLACE_OBJ: |
354 |
VpStartPlaceSizing(e->place.tile, VPM_X_AND_Y_LIMITED); |
|
355 |
VpSetPlaceSizingLimit(20); |
|
356 |
break; |
|
357 |
||
358 |
case WE_PLACE_DRAG: |
|
359 |
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); |
|
360 |
return; |
|
361 |
||
362 |
case WE_PLACE_MOUSEUP: |
|
363 |
if (e->click.pt.x != -1) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
364 |
DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL, |
0 | 365 |
CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); |
366 |
} |
|
367 |
break; |
|
368 |
||
369 |
case WE_TIMEOUT: |
|
370 |
UnclickSomeWindowButtons(w, 1<<16); |
|
371 |
break; |
|
372 |
||
373 |
case WE_ABORT_PLACE_OBJ: |
|
374 |
w->click_state = 0; |
|
375 |
SetWindowDirty(w); |
|
376 |
break; |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
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
|
381 |
{ 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
|
382 |
{ 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
|
383 |
{ 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
|
384 |
{ 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
|
385 |
{ 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
|
386 |
{ 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
|
387 |
{ 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
|
388 |
{ 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
|
389 |
{ 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
|
390 |
{ 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
|
391 |
{ 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
|
392 |
{ 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
|
393 |
{ 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
|
394 |
{ 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
|
395 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 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_CLOSEBOX, 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
|
397 |
{ WIDGETS_END}, |
0 | 398 |
}; |
399 |
||
400 |
static const WindowDesc _build_trees_desc = { |
|
401 |
497, 22, 143, 171, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
598
diff
changeset
|
402 |
WC_BUILD_TREES, WC_SCEN_LAND_GEN, |
0 | 403 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
404 |
_build_trees_widgets, |
|
405 |
BuildTreesWndProc |
|
406 |
}; |
|
407 |
||
408 |
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
|
409 |
{ 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
|
410 |
{ 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
|
411 |
{ 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
|
412 |
{ 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
|
413 |
{ 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
|
414 |
{ 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
|
415 |
{ 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
|
416 |
{ 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
|
417 |
{ 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
|
418 |
{ 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
|
419 |
{ 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
|
420 |
{ 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
|
421 |
{ 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
|
422 |
{ 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
|
423 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 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_CLOSEBOX, RESIZE_NONE, 14, 2, 140, 157, 168, STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
425 |
{ WWT_CLOSEBOX, 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
|
426 |
{ WIDGETS_END}, |
0 | 427 |
}; |
428 |
||
429 |
static const WindowDesc _build_trees_scen_desc = { |
|
430 |
-1, -1, 143, 184, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
598
diff
changeset
|
431 |
WC_BUILD_TREES,0, |
0 | 432 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
433 |
_build_trees_scen_widgets, |
|
434 |
BuildTreesWndProc |
|
435 |
}; |
|
436 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
437 |
|
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
|
438 |
void ShowBuildTreesToolbar(void) |
0 | 439 |
{ |
1846
c4c9ded67c3c
(svn r2351) -Fix: It was possible to open more than one tree window
tron
parents:
1843
diff
changeset
|
440 |
AllocateWindowDescFront(&_build_trees_desc, 0); |
0 | 441 |
} |
442 |
||
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
|
443 |
void ShowBuildTreesScenToolbar(void) |
0 | 444 |
{ |
445 |
AllocateWindowDescFront(&_build_trees_scen_desc, 0); |
|
446 |
} |
|
447 |
||
674
63eb544b0689
(svn r1112) -Fix: _decode_parameters was increased to [20], but not all temp-dparams were
truelight
parents:
635
diff
changeset
|
448 |
static uint32 _errmsg_decode_params[20]; |
0 | 449 |
static StringID _errmsg_message_1, _errmsg_message_2; |
450 |
static uint _errmsg_duration; |
|
451 |
||
452 |
||
453 |
static const Widget _errmsg_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
454 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
455 |
{ 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
|
456 |
{ 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
|
457 |
{ WIDGETS_END}, |
0 | 458 |
}; |
459 |
||
460 |
static const Widget _errmsg_face_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
461 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
462 |
{ 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
|
463 |
{ 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
|
464 |
{ WIDGETS_END}, |
0 | 465 |
}; |
466 |
||
467 |
static void ErrmsgWndProc(Window *w, WindowEvent *e) |
|
468 |
{ |
|
469 |
switch(e->event) { |
|
470 |
case WE_PAINT: |
|
471 |
COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
|
472 |
DrawWindowWidgets(w); |
|
473 |
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
|
474 |
if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { |
0 | 475 |
DrawStringMultiCenter( |
476 |
120, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
477 |
(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15), |
0 | 478 |
_errmsg_message_2, |
479 |
238); |
|
480 |
if (_errmsg_message_1 != INVALID_STRING_ID) |
|
481 |
DrawStringMultiCenter( |
|
482 |
120, |
|
483 |
30, |
|
484 |
_errmsg_message_1, |
|
485 |
238); |
|
486 |
} else { |
|
2475 | 487 |
const Player* p = GetPlayer(GetDParamX(_errmsg_decode_params,2)); |
0 | 488 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
489 |
||
490 |
DrawStringMultiCenter( |
|
491 |
214, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
492 |
(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45), |
0 | 493 |
_errmsg_message_2, |
494 |
238); |
|
495 |
if (_errmsg_message_1 != INVALID_STRING_ID) |
|
496 |
DrawStringMultiCenter( |
|
497 |
214, |
|
498 |
90, |
|
499 |
_errmsg_message_1, |
|
500 |
238); |
|
501 |
} |
|
502 |
break; |
|
503 |
||
504 |
case WE_MOUSELOOP: |
|
505 |
if (_right_button_down) |
|
506 |
DeleteWindow(w); |
|
507 |
break; |
|
508 |
case WE_4: |
|
509 |
if (!--_errmsg_duration) |
|
510 |
DeleteWindow(w); |
|
511 |
break; |
|
512 |
case WE_DESTROY: { |
|
1860
cc0019652d0e
(svn r2366) Use SetRedErrorSquare() instead of home brewed version
tron
parents:
1846
diff
changeset
|
513 |
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
|
514 |
_switch_mode_errorstr = INVALID_STRING_ID; |
0 | 515 |
break; |
516 |
} |
|
517 |
||
518 |
case WE_KEYPRESS: |
|
519 |
if (e->keypress.keycode == WKC_SPACE) { |
|
520 |
// Don't continue. |
|
521 |
e->keypress.cont = false; |
|
522 |
DeleteWindow(w); |
|
523 |
} |
|
524 |
break; |
|
525 |
} |
|
526 |
} |
|
527 |
||
528 |
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) |
|
529 |
{ |
|
530 |
Window *w; |
|
531 |
ViewPort *vp; |
|
532 |
Point pt; |
|
533 |
||
534 |
DeleteWindowById(WC_ERRMSG, 0); |
|
535 |
||
536 |
//assert(msg_2); |
|
537 |
if (msg_2 == 0) msg_2 = STR_EMPTY; |
|
538 |
||
539 |
_errmsg_message_1 = msg_1; |
|
540 |
_errmsg_message_2 = msg_2; |
|
541 |
COPY_OUT_DPARAM(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); |
|
542 |
_errmsg_duration = _patches.errmsg_duration; |
|
543 |
if (!_errmsg_duration) |
|
544 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
545 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
546 |
if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) { |
0 | 547 |
|
548 |
if ( (x|y) != 0) { |
|
549 |
pt = RemapCoords2(x, y); |
|
550 |
for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {} |
|
551 |
vp = w->viewport; |
|
552 |
||
553 |
// move x pos to opposite corner |
|
554 |
pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left; |
|
555 |
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
|
556 |
|
0 | 557 |
// move y pos to opposite corner |
558 |
pt.y = ((pt.y - vp->virtual_top) >> vp->zoom) + vp->top; |
|
559 |
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
|
560 |
|
0 | 561 |
} else { |
562 |
pt.x = (_screen.width - 240) >> 1; |
|
563 |
pt.y = (_screen.height - 46) >> 1; |
|
564 |
} |
|
565 |
w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
|
566 |
} else { |
|
567 |
if ( (x|y) != 0) { |
|
568 |
pt = RemapCoords2(x, y); |
|
569 |
for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {} |
|
570 |
vp = w->viewport; |
|
571 |
pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
|
572 |
pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
|
573 |
} else { |
|
574 |
pt.x = (_screen.width - 334) >> 1; |
|
575 |
pt.y = (_screen.height - 137) >> 1; |
|
576 |
} |
|
577 |
w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
|
578 |
} |
|
579 |
||
580 |
w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
|
581 |
} |
|
582 |
||
583 |
||
584 |
void ShowEstimatedCostOrIncome(int32 cost, int x, int y) |
|
585 |
{ |
|
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
|
586 |
StringID msg = STR_0805_ESTIMATED_COST; |
0 | 587 |
|
588 |
if (cost < 0) { |
|
589 |
cost = -cost; |
|
590 |
msg = STR_0807_ESTIMATED_INCOME; |
|
591 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
592 |
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
|
593 |
ShowErrorMessage(INVALID_STRING_ID, msg, x, y); |
0 | 594 |
} |
595 |
||
596 |
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost) |
|
597 |
{ |
|
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
|
598 |
StringID msg; |
0 | 599 |
Point pt = RemapCoords(x,y,z); |
600 |
||
601 |
msg = STR_0801_COST; |
|
602 |
if (cost < 0) { |
|
603 |
cost = -cost; |
|
604 |
msg = STR_0803_INCOME; |
|
605 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
606 |
SetDParam(0, cost); |
0 | 607 |
AddTextEffect(msg, pt.x, pt.y, 0x250); |
608 |
} |
|
609 |
||
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
610 |
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
|
611 |
{ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
612 |
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
|
613 |
|
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
614 |
SetDParam(0, cost); |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
615 |
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
|
616 |
} |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
617 |
|
2275
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
618 |
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
|
619 |
{ 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
|
620 |
{ WIDGETS_END}, |
0 | 621 |
}; |
622 |
||
623 |
||
624 |
static void TooltipsWndProc(Window *w, WindowEvent *e) |
|
625 |
{ |
|
626 |
||
627 |
switch(e->event) { |
|
628 |
case WE_PAINT: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
629 |
GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
0 | 630 |
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
631 |
DrawStringMultiCenter((w->width>>1), (w->height>>1)-5, WP(w,tooltips_d).string_id, 197); |
|
632 |
break; |
|
633 |
} |
|
634 |
case WE_MOUSELOOP: |
|
635 |
if (!_right_button_down) |
|
636 |
DeleteWindow(w); |
|
637 |
break; |
|
638 |
} |
|
639 |
} |
|
640 |
||
641 |
void GuiShowTooltips(StringID string_id) |
|
642 |
{ |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
643 |
char buffer[512]; |
0 | 644 |
Window *w; |
645 |
int right,bottom; |
|
646 |
int x,y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
647 |
|
0 | 648 |
if (string_id == 0) |
649 |
return; |
|
650 |
||
651 |
w = FindWindowById(WC_TOOLTIPS, 0); |
|
652 |
if (w != NULL) { |
|
653 |
if (WP(w,tooltips_d).string_id == string_id) |
|
654 |
return; |
|
655 |
DeleteWindow(w); |
|
656 |
} |
|
657 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
658 |
GetString(buffer, string_id); |
0 | 659 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
660 |
right = GetStringWidth(buffer) + 4; |
0 | 661 |
|
662 |
bottom = 14; |
|
663 |
if (right > 200) { |
|
664 |
bottom += ((right - 4) / 176) * 10; |
|
665 |
right = 200; |
|
666 |
} |
|
667 |
||
668 |
y = _cursor.pos.y + 30; |
|
669 |
if (y < 22) y = 22; |
|
670 |
||
671 |
if (y > (_screen.height - 44) && (y-=52) > (_screen.height - 44)) |
|
672 |
y = (_screen.height - 44); |
|
673 |
||
674 |
x = _cursor.pos.x - (right >> 1); |
|
675 |
if (x < 0) x = 0; |
|
676 |
if (x > (_screen.width - right)) x = _screen.width - right; |
|
677 |
||
678 |
w = AllocateWindow(x, y, right, bottom, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
|
679 |
WP(w,tooltips_d).string_id = string_id; |
|
680 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
|
2275
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
681 |
w->widget[0].right = right; |
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
682 |
w->widget[0].bottom = bottom; |
0 | 683 |
} |
684 |
||
685 |
||
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
686 |
static void DrawStationCoverageText(const AcceptedCargo accepts, |
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
687 |
int str_x, int str_y, uint mask) |
0 | 688 |
{ |
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
689 |
char *b = _userstring; |
0 | 690 |
int i; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
691 |
|
1553
4976359e2bf9
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
692 |
b = InlineString(b, STR_000D_ACCEPTS); |
0 | 693 |
|
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
694 |
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
|
695 |
if (accepts[i] >= 8 && mask & 1) { |
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
696 |
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
|
697 |
*b++ = ','; |
4976359e2bf9
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
698 |
*b++ = ' '; |
0 | 699 |
} |
700 |
} |
|
701 |
||
1329 | 702 |
if (b == &_userstring[3]) { |
1553
4976359e2bf9
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
703 |
b = InlineString(b, STR_00D0_NOTHING); |
4976359e2bf9
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
704 |
*b++ = '\0'; |
0 | 705 |
} else { |
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
706 |
b[-2] = '\0'; |
0 | 707 |
} |
708 |
||
709 |
DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
|
710 |
} |
|
711 |
||
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
712 |
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) { |
0 | 713 |
int x = _thd.pos.x; |
714 |
int y = _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
|
715 |
AcceptedCargo accepts; |
0 | 716 |
if (x != -1) { |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
717 |
GetAcceptanceAroundTiles(accepts, TileVirtXY(x, y), _thd.size.x / 16, _thd.size.y / 16 , rad); |
0 | 718 |
DrawStationCoverageText(accepts, sx, sy, mask); |
719 |
} |
|
720 |
} |
|
721 |
||
2549 | 722 |
void CheckRedrawStationCoverage(const Window* w) |
0 | 723 |
{ |
2549 | 724 |
if (_thd.dirty & 1) { |
725 |
_thd.dirty &= ~1; |
|
0 | 726 |
SetWindowDirty(w); |
727 |
} |
|
728 |
} |
|
729 |
||
730 |
||
731 |
void UnclickSomeWindowButtons(Window *w, uint32 mask) |
|
732 |
{ |
|
733 |
uint32 x = w->click_state & mask; |
|
734 |
int i = 0; |
|
735 |
w->click_state ^= x; |
|
736 |
do { |
|
2549 | 737 |
if (x & 1) InvalidateWidget(w, i); |
738 |
} while (i++, x >>= 1); |
|
0 | 739 |
} |
740 |
||
741 |
||
742 |
void UnclickWindowButtons(Window *w) |
|
743 |
{ |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
744 |
bool sticky = false; |
2549 | 745 |
if (w->desc_flags & WDF_STICKY_BUTTON && HASBIT(w->click_state, 2)) sticky = true; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
746 |
|
0 | 747 |
UnclickSomeWindowButtons(w, (uint32)-1); |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
748 |
|
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
749 |
if (sticky) SETBIT(w->click_state, 2); |
0 | 750 |
} |
751 |
||
752 |
||
753 |
void SetVScrollCount(Window *w, int num) |
|
754 |
{ |
|
755 |
w->vscroll.count = num; |
|
756 |
num -= w->vscroll.cap; |
|
757 |
if (num < 0) num = 0; |
|
758 |
if (num < w->vscroll.pos) w->vscroll.pos = num; |
|
759 |
} |
|
760 |
||
842 | 761 |
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
|
762 |
{ |
842 | 763 |
w->vscroll2.count = num; |
764 |
num -= w->vscroll2.cap; |
|
765 |
if (num < 0) num = 0; |
|
766 |
if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
|
767 |
} |
|
768 |
||
0 | 769 |
void SetHScrollCount(Window *w, int num) |
770 |
{ |
|
771 |
w->hscroll.count = num; |
|
772 |
num -= w->hscroll.cap; |
|
773 |
if (num < 0) num = 0; |
|
774 |
if (num < w->hscroll.pos) w->hscroll.pos = num; |
|
775 |
} |
|
776 |
||
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
|
777 |
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
|
778 |
{ |
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
|
779 |
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
|
780 |
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
|
781 |
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
|
782 |
} |
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
|
783 |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
784 |
/** |
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 |
* 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
|
786 |
* 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
|
787 |
* @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
|
788 |
* @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
|
789 |
* @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
|
790 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
791 |
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
|
792 |
{ |
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 |
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
|
794 |
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
|
795 |
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
|
796 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
797 |
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
|
798 |
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
|
799 |
} 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
|
800 |
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
|
801 |
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
|
802 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
803 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
804 |
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
|
805 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
806 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
807 |
/** |
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
|
808 |
* 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
|
809 |
* @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
|
810 |
*/ |
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
|
811 |
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
|
812 |
{ |
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
|
813 |
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
|
814 |
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
|
815 |
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
|
816 |
} |
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
|
817 |
|
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
|
818 |
/** |
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
|
819 |
* 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
|
820 |
* 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
|
821 |
* @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
|
822 |
* @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
|
823 |
* @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
|
824 |
*/ |
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 |
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
|
826 |
{ |
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 |
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
|
828 |
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
|
829 |
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
|
830 |
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
|
831 |
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
|
832 |
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
|
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 |
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
|
835 |
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
|
836 |
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
|
837 |
} |
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 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
|
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 |
|
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 |
* 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
|
843 |
* 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
|
844 |
* @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
|
845 |
* @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
|
846 |
* @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
|
847 |
*/ |
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 |
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
|
849 |
{ |
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 |
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
|
851 |
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
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
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
|
856 |
} |
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 |
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
|
858 |
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
|
859 |
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
|
860 |
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
|
861 |
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
|
862 |
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
|
863 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
864 |
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
|
865 |
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
|
866 |
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
|
867 |
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
|
868 |
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
|
869 |
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
|
870 |
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
|
871 |
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
|
872 |
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
|
873 |
} |
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 |
|
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 |
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
|
876 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
877 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
878 |
/** |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
879 |
* 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
|
880 |
* 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
|
881 |
* 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
|
882 |
* @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
|
883 |
*/ |
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 |
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
|
885 |
{ |
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 |
char *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
|
887 |
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
|
888 |
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
|
889 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
890 |
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
|
891 |
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
|
892 |
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
|
893 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
894 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
895 |
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
|
896 |
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
|
897 |
} |
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
|
898 |
|
0 | 899 |
int HandleEditBoxKey(Window *w, int wid, WindowEvent *we) |
900 |
{ |
|
901 |
we->keypress.cont = false; |
|
902 |
||
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
|
903 |
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
|
904 |
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
|
905 |
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
|
906 |
case (WKC_CTRL | 'V'): |
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 |
if (InsertTextBufferClipboard(&WP(w, querystr_d).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
|
908 |
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
|
909 |
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
|
910 |
case (WKC_CTRL | 'U'): |
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
|
911 |
DeleteTextBufferAll(&WP(w, querystr_d).text); |
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
|
912 |
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
|
913 |
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
|
914 |
case WKC_BACKSPACE: case 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
|
915 |
if (DeleteTextBufferChar(&WP(w, querystr_d).text, 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
|
916 |
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
|
917 |
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
|
918 |
case WKC_LEFT: case WKC_RIGHT: case WKC_END: 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
|
919 |
if (MoveTextBufferPos(&WP(w, querystr_d).text, 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
|
920 |
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
|
921 |
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
|
922 |
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
|
923 |
if (IsValidAsciiChar(we->keypress.ascii)) { |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
924 |
if (InsertTextBufferChar(&WP(w, querystr_d).text, we->keypress.ascii)) |
0 | 925 |
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
|
926 |
} else // key wasn't caught |
0 | 927 |
we->keypress.cont = true; |
928 |
} |
|
929 |
||
930 |
return 0; |
|
931 |
} |
|
932 |
||
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
|
933 |
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
|
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 |
/* 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
|
936 |
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
|
937 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
938 |
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
|
939 |
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
|
940 |
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
|
941 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
942 |
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
|
943 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
944 |
|
0 | 945 |
void HandleEditBox(Window *w, int wid) |
946 |
{ |
|
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
|
947 |
if (HandleCaret(&WP(w, querystr_d).text)) |
0 | 948 |
InvalidateWidget(w, wid); |
949 |
} |
|
950 |
||
951 |
void DrawEditBox(Window *w, int wid) |
|
952 |
{ |
|
953 |
const Widget *wi = w->widget + 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
|
954 |
const Textbuf *tb = &WP(w,querystr_d).text; |
0 | 955 |
|
956 |
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
|
957 |
DoDrawString(tb->buf, wi->left+2, wi->top+1, 8); |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
958 |
if (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
|
959 |
DoDrawString("_", wi->left + 2 + tb->caretxoffs, wi->top + 1, 12); |
0 | 960 |
} |
961 |
||
962 |
static void QueryStringWndProc(Window *w, WindowEvent *e) |
|
963 |
{ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
964 |
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
|
965 |
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
|
966 |
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
|
967 |
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
|
968 |
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
|
969 |
break; |
733f83b6483a
(svn r2348) - Fix: Do not scroll the game with the arrow keys when the chatbox is open
Darkvater
parents:
1826
diff
changeset
|
970 |
|
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
|
971 |
case WE_PAINT: |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
972 |
SetDParam(0, WP(w,querystr_d).caption); |
0 | 973 |
DrawWindowWidgets(w); |
974 |
||
975 |
DrawEditBox(w, 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
|
976 |
break; |
0 | 977 |
|
978 |
case WE_CLICK: |
|
979 |
switch(e->click.widget) { |
|
980 |
case 3: DeleteWindow(w); break; |
|
981 |
case 4: |
|
982 |
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
|
983 |
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
|
984 |
strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).orig) == 0) { |
0 | 985 |
DeleteWindow(w); |
986 |
} 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
|
987 |
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
|
988 |
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
|
989 |
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
|
990 |
Window *parent; |
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
991 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
992 |
// 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
|
993 |
closed = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
994 |
|
598
200de7111fa9
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
995 |
DeleteWindow(w); |
200de7111fa9
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
996 |
|
390
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
997 |
parent = FindWindowById(wnd_class, wnd_num); |
0 | 998 |
if (parent != NULL) { |
999 |
WindowEvent e; |
|
1000 |
e.event = WE_ON_EDIT_TEXT; |
|
1001 |
e.edittext.str = buf; |
|
1002 |
parent->wndproc(parent, &e); |
|
1003 |
} |
|
1004 |
} |
|
1005 |
break; |
|
1006 |
} |
|
1007 |
break; |
|
1008 |
||
1009 |
case WE_MOUSELOOP: { |
|
1010 |
if (!FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num)) { |
|
1011 |
DeleteWindow(w); |
|
1012 |
return; |
|
1013 |
} |
|
1014 |
HandleEditBox(w, 5); |
|
1015 |
} break; |
|
1016 |
||
1017 |
case WE_KEYPRESS: { |
|
1018 |
switch(HandleEditBoxKey(w, 5, e)) { |
|
1019 |
case 1: // Return |
|
1020 |
goto press_ok; |
|
1021 |
case 2: // Escape |
|
1022 |
DeleteWindow(w); |
|
1023 |
break; |
|
1024 |
} |
|
1025 |
} break; |
|
1026 |
||
1027 |
case WE_DESTROY: |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1028 |
// 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
|
1029 |
if (!closed) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1030 |
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
|
1031 |
if (parent != NULL) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1032 |
WindowEvent e; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1033 |
e.event = WE_ON_EDIT_TEXT_CANCEL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1034 |
parent->wndproc(parent, &e); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1035 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1036 |
} |
0 | 1037 |
_query_string_active = false; |
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
|
1038 |
CLRBIT(_no_scroll, SCROLL_EDIT); |
0 | 1039 |
break; |
1040 |
} |
|
1041 |
} |
|
1042 |
||
1043 |
static const Widget _query_string_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1044 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1045 |
{ 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
|
1046 |
{ 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
|
1047 |
{ 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
|
1048 |
{ 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
|
1049 |
{ 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
|
1050 |
{ WIDGETS_END}, |
0 | 1051 |
}; |
1052 |
||
1053 |
static const WindowDesc _query_string_desc = { |
|
1054 |
190, 219, 260, 42, |
|
1055 |
WC_QUERY_STRING,0, |
|
1056 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1057 |
_query_string_widgets, |
|
1058 |
QueryStringWndProc |
|
1059 |
}; |
|
1060 |
||
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
|
1061 |
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
|
1062 |
static char _orig_str_buf[lengthof(_edit_str_buf)]; |
0 | 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 |
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number) |
0 | 1065 |
{ |
1066 |
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
|
1067 |
uint realmaxlen = maxlen & ~0x1000; |
0 | 1068 |
|
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
|
1069 |
assert(realmaxlen < lengthof(_edit_str_buf)); |
0 | 1070 |
|
1071 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1072 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1073 |
||
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
|
1074 |
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
|
1075 |
|
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
|
1076 |
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
|
1077 |
_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
|
1078 |
|
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1079 |
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
|
1080 |
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
|
1081 |
} 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
|
1082 |
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
|
1083 |
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
|
1084 |
} |
0 | 1085 |
|
1086 |
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
|
1087 |
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
|
1088 |
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
|
1089 |
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
|
1090 |
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
|
1091 |
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
|
1092 |
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
|
1093 |
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
|
1094 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
0 | 1095 |
|
1096 |
_query_string_active = true; |
|
1097 |
} |
|
1098 |
||
1099 |
static const Widget _load_dialog_1_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1100 |
{ WWT_TEXTBTN, 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
|
1101 |
{ 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
|
1102 |
{ 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
|
1103 |
{ 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
|
1104 |
{ 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
|
1105 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 256, 48, 293, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1106 |
{ 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
|
1107 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_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
|
1108 |
{ 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
|
1109 |
{ 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
|
1110 |
{ WIDGETS_END}, |
0 | 1111 |
}; |
1112 |
||
1113 |
static const Widget _load_dialog_2_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1114 |
{ WWT_TEXTBTN, 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
|
1115 |
{ 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
|
1116 |
{ 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
|
1117 |
{ 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
|
1118 |
{ 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
|
1119 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 256, 48, 293, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1120 |
{ 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
|
1121 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_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
|
1122 |
{ 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
|
1123 |
{ 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
|
1124 |
{ WIDGETS_END}, |
0 | 1125 |
}; |
1126 |
||
1127 |
static const Widget _save_dialog_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1128 |
{ WWT_TEXTBTN, 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
|
1129 |
{ 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
|
1130 |
{ 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
|
1131 |
{ 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
|
1132 |
{ 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
|
1133 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 256, 48, 291, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1134 |
{ 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
|
1135 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_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
|
1136 |
{ 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
|
1137 |
{ 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
|
1138 |
{ 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
|
1139 |
{ 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
|
1140 |
{ 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
|
1141 |
{ 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
|
1142 |
{ WIDGETS_END}, |
0 | 1143 |
}; |
1144 |
||
1145 |
static const Widget _save_dialog_scen_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1146 |
{ WWT_TEXTBTN, 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
|
1147 |
{ 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
|
1148 |
{ 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
|
1149 |
{ 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
|
1150 |
{ 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
|
1151 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 256, 48, 291, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1152 |
{ 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
|
1153 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_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
|
1154 |
{ 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
|
1155 |
{ 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
|
1156 |
{ 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
|
1157 |
{ 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
|
1158 |
{ 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
|
1159 |
{ 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
|
1160 |
{ WIDGETS_END}, |
0 | 1161 |
}; |
1162 |
||
1163 |
||
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2255
diff
changeset
|
1164 |
// Colors for fios types |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2255
diff
changeset
|
1165 |
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
|
1166 |
|
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
|
1167 |
void BuildFileList(void) |
0 | 1168 |
{ |
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
|
1169 |
_fios_path_changed = true; |
0 | 1170 |
FiosFreeSavegameList(); |
2549 | 1171 |
switch (_saveload_mode) { |
1172 |
case SLD_NEW_GAME: |
|
1173 |
case SLD_LOAD_SCENARIO: |
|
1174 |
case SLD_SAVE_SCENARIO: |
|
1175 |
_fios_list = FiosGetScenarioList(&_fios_num, _saveload_mode); |
|
1176 |
break; |
|
1177 |
||
1178 |
default: |
|
1179 |
_fios_list = FiosGetSavegameList(&_fios_num, _saveload_mode); |
|
1180 |
break; |
|
1181 |
} |
|
0 | 1182 |
} |
1183 |
||
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
|
1184 |
static void DrawFiosTexts(uint maxw) |
0 | 1185 |
{ |
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
|
1186 |
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
|
1187 |
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
|
1188 |
static uint32 tot = 0; |
0 | 1189 |
|
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
|
1190 |
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
|
1191 |
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
|
1192 |
_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
|
1193 |
} |
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
|
1194 |
|
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
|
1195 |
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
|
1196 |
DrawString(2, 37, str, 0); |
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2100
diff
changeset
|
1197 |
DoDrawStringTruncated(path, 2, 27, 16, maxw); |
0 | 1198 |
} |
1199 |
||
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
|
1200 |
static void MakeSortedSaveGameList(void) |
0 | 1201 |
{ |
1202 |
/* Directories are always above the files (FIOS_TYPE_DIR) |
|
1203 |
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE) |
|
1204 |
* Only sort savegames/scenarios, not directories |
|
1205 |
*/ |
|
1206 |
||
1207 |
int i, sort_start, sort_end, s_amount; |
|
1208 |
i = sort_start = sort_end = 0; |
|
1209 |
||
1210 |
while (i < _fios_num) { |
|
1211 |
if (_fios_list[i].type == FIOS_TYPE_DIR || _fios_list[i].type == FIOS_TYPE_PARENT) |
|
1212 |
sort_start++; |
|
1213 |
||
1214 |
if (_fios_list[i].type == FIOS_TYPE_DRIVE) |
|
1215 |
sort_end++; |
|
1216 |
||
1217 |
i++; |
|
1218 |
} |
|
1219 |
||
1220 |
s_amount = _fios_num - sort_start - sort_end; |
|
1105 | 1221 |
if (s_amount > 0) |
0 | 1222 |
qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems); |
1223 |
} |
|
1224 |
||
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1225 |
static void GenerateFileName(void) |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1226 |
{ |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1227 |
const Player *p; |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1228 |
/* 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
|
1229 |
Let's use the name of player #0 for now. */ |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1230 |
if (_local_player < MAX_PLAYERS) |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
1231 |
p = GetPlayer(_local_player); |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1232 |
else |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
1233 |
p = GetPlayer(0); |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1234 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1235 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1236 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1237 |
SetDParam(2, _date); |
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1238 |
GetString(_edit_str_buf, STR_4004); |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1239 |
} |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1240 |
|
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1241 |
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
|
1242 |
|
0 | 1243 |
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) |
1244 |
{ |
|
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
|
1245 |
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
|
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 |
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
|
1248 |
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
|
1249 |
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
|
1250 |
switch (_saveload_mode) { |
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
|
1251 |
case SLD_SAVE_GAME: case SLD_LOAD_GAME: |
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
|
1252 |
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
|
1253 |
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
|
1254 |
case SLD_SAVE_SCENARIO: case SLD_LOAD_SCENARIO: |
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
|
1255 |
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
|
1256 |
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
|
1257 |
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
|
1258 |
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
|
1259 |
} |
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
|
1260 |
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
|
1261 |
} |
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
|
1262 |
|
0 | 1263 |
case WE_PAINT: { |
1264 |
int y,pos; |
|
1265 |
const FiosItem *item; |
|
1266 |
||
1267 |
SetVScrollCount(w, _fios_num); |
|
1268 |
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
|
1269 |
DrawFiosTexts(w->width); |
0 | 1270 |
|
1271 |
if (_savegame_sort_dirty) { |
|
1272 |
_savegame_sort_dirty = false; |
|
1273 |
MakeSortedSaveGameList(); |
|
1274 |
} |
|
1275 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1276 |
GfxFillRect(w->widget[6].left + 1, w->widget[6].top + 1, w->widget[6].right, w->widget[6].bottom, 0xD7); |
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1277 |
DoDrawString( |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1278 |
_savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW, |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1279 |
_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
|
1280 |
15, 16 |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1281 |
); |
0 | 1282 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1283 |
y = w->widget[6].top + 1; |
0 | 1284 |
pos = w->vscroll.pos; |
1285 |
while (pos < _fios_num) { |
|
1286 |
item = _fios_list + pos; |
|
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2100
diff
changeset
|
1287 |
DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18); |
0 | 1288 |
pos++; |
2549 | 1289 |
y += 10; |
1290 |
if (y >= w->vscroll.cap * 10 + w->widget[6].top + 1) break; |
|
0 | 1291 |
} |
1292 |
||
1293 |
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
|
1294 |
DrawEditBox(w, 10); |
0 | 1295 |
} |
1296 |
break; |
|
1297 |
} |
|
1298 |
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
|
1299 |
switch (e->click.widget) { |
0 | 1300 |
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
|
1301 |
_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
|
1302 |
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
0 | 1303 |
_savegame_sort_dirty = true; |
1304 |
SetWindowDirty(w); |
|
1305 |
break; |
|
1306 |
||
1307 |
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
|
1308 |
_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
|
1309 |
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
0 | 1310 |
_savegame_sort_dirty = true; |
1311 |
SetWindowDirty(w); |
|
1312 |
break; |
|
1313 |
||
1314 |
case 6: { /* Click the listbox */ |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1315 |
int y = (e->click.pt.y - w->widget[6].top - 1) / 10; |
0 | 1316 |
char *name; |
1317 |
const FiosItem *file; |
|
1318 |
||
1319 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) |
|
1320 |
return; |
|
1321 |
||
1322 |
file = _fios_list + y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1323 |
|
0 | 1324 |
if ((name = FiosBrowseTo(file)) != 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
|
1325 |
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
|
1326 |
_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
|
1327 |
|
0 | 1328 |
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
|
1329 |
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
|
1330 |
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
|
1331 |
|
0 | 1332 |
DeleteWindow(w); |
1333 |
} else { |
|
1334 |
// SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox |
|
2128
f5baf0b86451
(svn r2638) - Fix: Unable to delete savegames. Deleting TTDLX savegames is still broken as it was always broken, but since they don't even show up; we might as well call it a feature.
Darkvater
parents:
2103
diff
changeset
|
1335 |
ttd_strlcpy(WP(w, querystr_d).text.buf, file->name, 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
|
1336 |
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
|
1337 |
InvalidateWidget(w, 10); |
0 | 1338 |
} |
1339 |
} else { |
|
1340 |
// Changed directory, need repaint. |
|
1341 |
SetWindowDirty(w); |
|
1342 |
BuildFileList(); |
|
1343 |
} |
|
1344 |
break; |
|
1345 |
} |
|
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
|
1346 |
case 7: /* OpenTTD 'button', jumps to OpenTTD directory */ |
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
|
1347 |
FiosBrowseTo(&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
|
1348 |
SetWindowDirty(w); |
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
|
1349 |
BuildFileList(); |
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
|
1350 |
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
|
1351 |
|
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
|
1352 |
case 11: case 12: /* Delete, Save game */ |
0 | 1353 |
break; |
1354 |
} |
|
1355 |
break; |
|
1356 |
case WE_MOUSELOOP: |
|
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
|
1357 |
HandleEditBox(w, 10); |
0 | 1358 |
break; |
1359 |
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
|
1360 |
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
|
1361 |
DeleteWindow(w); |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1362 |
return; |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1363 |
} |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1364 |
|
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1365 |
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
|
1366 |
if (HandleEditBoxKey(w, 10, e) == 1) /* Press Enter */ |
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
|
1367 |
HandleButtonClick(w, 12); |
0 | 1368 |
} |
1369 |
break; |
|
1370 |
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
|
1371 |
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
|
1372 |
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
|
1373 |
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
ddcaf9e333ff
(svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents:
2201
diff
changeset
|
1374 |
} |
0 | 1375 |
SetWindowDirty(w); |
1376 |
BuildFileList(); |
|
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
|
1377 |
if (_saveload_mode == SLD_SAVE_GAME) { |
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1378 |
GenerateFileName(); /* Reset file name to current date */ |
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
|
1379 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
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
|
1380 |
} |
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
|
1381 |
} else if (HASBIT(w->click_state, 12)) { /* Save button clicked */ |
0 | 1382 |
_switch_mode = SM_SAVE; |
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
|
1383 |
FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf); |
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1384 |
|
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1385 |
/* 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
|
1386 |
if (_game_mode == GM_EDITOR) StartupEngines(); |
0 | 1387 |
} |
1388 |
break; |
|
1389 |
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
|
1390 |
// 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
|
1391 |
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
|
1392 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
0 | 1393 |
_query_string_active = false; |
1394 |
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
|
1395 |
CLRBIT(_no_scroll, SCROLL_SAVE); |
0 | 1396 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1397 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1398 |
/* 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
|
1399 |
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
|
1400 |
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
|
1401 |
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
|
1402 |
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
|
1403 |
|
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
|
1404 |
/* 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
|
1405 |
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
|
1406 |
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
|
1407 |
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
|
1408 |
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
|
1409 |
} |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1410 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1411 |
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
|
1412 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1413 |
} |
0 | 1414 |
} |
1415 |
||
1416 |
static const WindowDesc _load_dialog_desc = { |
|
1417 |
WDP_CENTER, WDP_CENTER, 257, 294, |
|
1418 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1419 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1420 |
_load_dialog_1_widgets, |
1421 |
SaveLoadDlgWndProc, |
|
1422 |
}; |
|
1423 |
||
1424 |
static const WindowDesc _load_dialog_scen_desc = { |
|
1425 |
WDP_CENTER, WDP_CENTER, 257, 294, |
|
1426 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1427 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1428 |
_load_dialog_2_widgets, |
1429 |
SaveLoadDlgWndProc, |
|
1430 |
}; |
|
1431 |
||
1432 |
static const WindowDesc _save_dialog_desc = { |
|
1433 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1434 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1435 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1436 |
_save_dialog_widgets, |
1437 |
SaveLoadDlgWndProc, |
|
1438 |
}; |
|
1439 |
||
1440 |
static const WindowDesc _save_dialog_scen_desc = { |
|
1441 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1442 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1443 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1444 |
_save_dialog_scen_widgets, |
1445 |
SaveLoadDlgWndProc, |
|
1446 |
}; |
|
1447 |
||
1448 |
static const WindowDesc * const _saveload_dialogs[] = { |
|
1449 |
&_load_dialog_desc, |
|
1450 |
&_load_dialog_scen_desc, |
|
1451 |
&_save_dialog_desc, |
|
1452 |
&_save_dialog_scen_desc, |
|
1453 |
}; |
|
1454 |
||
1455 |
void ShowSaveLoadDialog(int mode) |
|
1456 |
{ |
|
1457 |
Window *w; |
|
1458 |
||
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
1459 |
SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0); |
0 | 1460 |
DeleteWindowById(WC_QUERY_STRING, 0); |
1461 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1462 |
||
1463 |
_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
|
1464 |
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
|
1465 |
|
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
|
1466 |
switch (mode) { |
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
|
1467 |
case SLD_SAVE_GAME: |
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
|
1468 |
GenerateFileName(); |
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
|
1469 |
break; |
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
|
1470 |
case SLD_SAVE_SCENARIO: |
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
|
1471 |
strcpy(_edit_str_buf, "UNNAMED"); |
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
|
1472 |
break; |
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
|
1473 |
} |
0 | 1474 |
|
1475 |
w = AllocateWindowDesc(_saveload_dialogs[mode]); |
|
1476 |
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
|
1477 |
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
|
1478 |
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
|
1479 |
w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
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
|
1480 |
SETBIT(w->click_state, 6); |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1481 |
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
|
1482 |
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
|
1483 |
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
|
1484 |
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
|
1485 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
0 | 1486 |
|
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
|
1487 |
// 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
|
1488 |
// will be unpaused in the WE_DESTROY event handler. |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1489 |
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
|
1490 |
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
950c3ac6e649
(svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents:
258
diff
changeset
|
1491 |
|
0 | 1492 |
BuildFileList(); |
1493 |
||
1494 |
ResetObjectToPlace(); |
|
1495 |
} |
|
1496 |
||
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
|
1497 |
void RedrawAutosave(void) |
0 | 1498 |
{ |
1499 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
|
1500 |
} |
|
1501 |
||
1502 |
static const Widget _select_scenario_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1503 |
{ WWT_TEXTBTN, 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
|
1504 |
{ 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
|
1505 |
{ 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
|
1506 |
{ 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
|
1507 |
{ 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
|
1508 |
{ 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
|
1509 |
{ 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
|
1510 |
{ 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
|
1511 |
{ 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
|
1512 |
{ WIDGETS_END}, |
0 | 1513 |
}; |
1514 |
||
1515 |
static void SelectScenarioWndProc(Window *w, WindowEvent *e) { |
|
1516 |
const int list_start = 45; |
|
1517 |
switch(e->event) { |
|
1518 |
case WE_PAINT: |
|
1519 |
{ |
|
1520 |
int y,pos; |
|
1521 |
const FiosItem *item; |
|
1522 |
||
1523 |
if (_savegame_sort_dirty) { |
|
1524 |
_savegame_sort_dirty = false; |
|
1525 |
MakeSortedSaveGameList(); |
|
1526 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1527 |
|
0 | 1528 |
SetVScrollCount(w, _fios_num); |
1529 |
||
1530 |
DrawWindowWidgets(w); |
|
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1531 |
DoDrawString( |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1532 |
_savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW, |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1533 |
_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
|
1534 |
15, 16 |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1535 |
); |
0 | 1536 |
DrawString(4, 32, STR_4010_GENERATE_RANDOM_NEW_GAME, 9); |
1537 |
||
1538 |
y = list_start; |
|
1539 |
pos = w->vscroll.pos; |
|
1540 |
while (pos < _fios_num) { |
|
1541 |
item = _fios_list + pos; |
|
2549 | 1542 |
DoDrawString(item->title, 4, y, _fios_colors[item->type]); |
0 | 1543 |
pos++; |
2549 | 1544 |
y += 10; |
1545 |
if (y >= w->vscroll.cap * 10 + list_start) break; |
|
0 | 1546 |
} |
1547 |
} |
|
1548 |
break; |
|
1549 |
||
1550 |
case WE_CLICK: |
|
1551 |
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
|
1552 |
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
|
1553 |
_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
|
1554 |
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
0 | 1555 |
_savegame_sort_dirty = true; |
1556 |
SetWindowDirty(w); |
|
1557 |
break; |
|
1558 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1559 |
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
|
1560 |
_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
|
1561 |
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
0 | 1562 |
_savegame_sort_dirty = true; |
1563 |
SetWindowDirty(w); |
|
1564 |
break; |
|
1565 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1566 |
case 6: /* Click the listbox */ |
1794
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1784
diff
changeset
|
1567 |
if (e->click.pt.y < list_start) |
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1784
diff
changeset
|
1568 |
GenRandomNewGame(Random(), InteractiveRandom()); |
0 | 1569 |
else { |
1570 |
char *name; |
|
1571 |
int y = (e->click.pt.y - list_start) / 10; |
|
1572 |
const FiosItem *file; |
|
1573 |
||
1574 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) |
|
1575 |
return; |
|
1576 |
||
1577 |
file = _fios_list + y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1578 |
|
2549 | 1579 |
name = FiosBrowseTo(file); |
1580 |
if (name != NULL) { |
|
0 | 1581 |
SetFiosType(file->type); |
1582 |
strcpy(_file_to_saveload.name, name); |
|
1583 |
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
|
1584 |
StartScenarioEditor(Random(), InteractiveRandom()); |
0 | 1585 |
} |
1586 |
} |
|
1587 |
break; |
|
1588 |
} |
|
1589 |
case WE_DESTROY: |
|
1590 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1591 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1592 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1593 |
/* 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
|
1594 |
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
|
1595 |
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
|
1596 |
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
|
1597 |
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
|
1598 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1599 |
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
|
1600 |
} break; |
0 | 1601 |
} |
1602 |
} |
|
1603 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1604 |
void SetFiosType(const byte fiostype) |
0 | 1605 |
{ |
1606 |
switch (fiostype) { |
|
2549 | 1607 |
case FIOS_TYPE_FILE: |
1608 |
case FIOS_TYPE_SCENARIO: |
|
1609 |
_file_to_saveload.mode = SL_LOAD; |
|
1610 |
break; |
|
1611 |
||
1612 |
case FIOS_TYPE_OLDFILE: |
|
1613 |
case FIOS_TYPE_OLD_SCENARIO: |
|
1614 |
_file_to_saveload.mode = SL_OLD_LOAD; |
|
1615 |
break; |
|
1616 |
||
1617 |
default: |
|
1618 |
_file_to_saveload.mode = SL_INVALID; |
|
1619 |
break; |
|
0 | 1620 |
} |
1621 |
} |
|
1622 |
||
1623 |
static const WindowDesc _select_scenario_desc = { |
|
1624 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1625 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1626 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1627 |
_select_scenario_widgets, |
1628 |
SelectScenarioWndProc |
|
1629 |
}; |
|
1630 |
||
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
|
1631 |
void AskForNewGameToStart(void) |
0 | 1632 |
{ |
1633 |
Window *w; |
|
1634 |
||
1635 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1636 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1637 |
||
1638 |
_saveload_mode = SLD_NEW_GAME; |
|
1639 |
BuildFileList(); |
|
1640 |
||
1641 |
w = AllocateWindowDesc(&_select_scenario_desc); |
|
1642 |
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
|
1643 |
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
|
1644 |
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
|
1645 |
w->resize.height = w->height - 10 * 17; // Minimum of 10 in the list |
0 | 1646 |
} |
1647 |
||
410 | 1648 |
static int32 ClickMoneyCheat(int32 p1, int32 p2) |
0 | 1649 |
{ |
1650 |
DoCommandP(0, -10000000, 0, NULL, CMD_MONEY_CHEAT); |
|
1651 |
return true; |
|
1652 |
} |
|
1653 |
||
1654 |
// p1 player to set to, p2 is -1 or +1 (down/up) |
|
410 | 1655 |
static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
0 | 1656 |
{ |
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1657 |
while(p1 >= 0 && p1 < MAX_PLAYERS) { |
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1658 |
if (_players[p1].is_active) { |
0 | 1659 |
_local_player = p1; |
138
6ab4d97d1034
(svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents:
108
diff
changeset
|
1660 |
MarkWholeScreenDirty(); |
0 | 1661 |
return _local_player; |
1662 |
} |
|
1663 |
p1 += p2; |
|
1664 |
} |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1665 |
|
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1666 |
return _local_player; |
0 | 1667 |
} |
1668 |
||
100 | 1669 |
// p1 -1 or +1 (down/up) |
1095 | 1670 |
static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
100 | 1671 |
{ |
104 | 1672 |
if(p1==-1) p1 = 3; |
1673 |
if(p1==4) p1 = 0; |
|
100 | 1674 |
_opt.landscape = p1; |
1675 |
GfxLoadSprites(); |
|
1676 |
MarkWholeScreenDirty(); |
|
1677 |
return _opt.landscape; |
|
1678 |
} |
|
1679 |
||
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
|
1680 |
extern void EnginesMonthlyLoop(void); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1681 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1682 |
// p2 1 (increase) or -1 (decrease) |
1095 | 1683 |
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
|
1684 |
{ |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1685 |
YearMonthDay ymd; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1686 |
ConvertDayToYMD(&ymd, _date); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1687 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1688 |
if((ymd.year==0 && p2==-1) || (ymd.year==170 && p2==1)) return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1689 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1690 |
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
|
1691 |
EnginesMonthlyLoop(); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1692 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1693 |
return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1694 |
} |
100 | 1695 |
|
0 | 1696 |
typedef int32 CheckButtonClick(int32, int32); |
1697 |
||
1345
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1698 |
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
|
1699 |
CE_BOOL = 0, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1700 |
CE_UINT8 = 1, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1701 |
CE_INT16 = 2, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1702 |
CE_UINT16 = 3, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1703 |
CE_INT32 = 4, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1704 |
CE_BYTE = 5, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1705 |
CE_CLICK = 6, |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1706 |
} ce_type; |
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1707 |
|
0 | 1708 |
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
|
1709 |
ce_type type; // type of selector |
0 | 1710 |
byte flags; // selector flags |
1711 |
StringID str; // string with descriptive text |
|
1712 |
void *variable; // pointer to the variable |
|
1713 |
bool *been_used; // has this cheat been used before? |
|
1714 |
CheckButtonClick *click_proc; // procedure |
|
1715 |
int16 min,max; // range for spinbox setting |
|
1716 |
uint16 step; // step for spinbox |
|
1717 |
} CheatEntry; |
|
1718 |
||
1719 |
static int32 ReadCE(const CheatEntry*ce) |
|
1720 |
{ |
|
1721 |
switch(ce->type) { |
|
1722 |
case CE_BOOL: return *(bool*)ce->variable; |
|
1723 |
case CE_UINT8: return *(uint8*)ce->variable; |
|
1724 |
case CE_INT16: return *(int16*)ce->variable; |
|
1725 |
case CE_UINT16: return *(uint16*)ce->variable; |
|
1726 |
case CE_INT32: return *(int32*)ce->variable; |
|
1727 |
case CE_BYTE: return *(byte*)ce->variable; |
|
1728 |
case CE_CLICK: return 0; |
|
1729 |
default: |
|
1730 |
NOT_REACHED(); |
|
1731 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1732 |
|
0 | 1733 |
/* useless, but avoids compiler warning this way */ |
1734 |
return 0; |
|
1735 |
} |
|
1736 |
||
1737 |
static void WriteCE(const CheatEntry *ce, int32 val) |
|
1738 |
{ |
|
1739 |
switch(ce->type) { |
|
1740 |
case CE_BOOL: *(bool*)ce->variable = (bool)val; break; |
|
1741 |
case CE_BYTE: *(byte*)ce->variable = (byte)val; break; |
|
1742 |
case CE_UINT8: *(uint8*)ce->variable = (uint8)val; break; |
|
1743 |
case CE_INT16: *(int16*)ce->variable = (int16)val; break; |
|
1744 |
case CE_UINT16: *(uint16*)ce->variable = (uint16)val; break; |
|
1745 |
case CE_INT32: *(int32*)ce->variable = val; break; |
|
1746 |
case CE_CLICK: break; |
|
1747 |
default: |
|
1748 |
NOT_REACHED(); |
|
1749 |
} |
|
1750 |
} |
|
1751 |
||
1752 |
||
1753 |
static const CheatEntry _cheats_ui[] = { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
1754 |
{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
|
1755 |
{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
|
1756 |
{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
|
1757 |
{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
|
1758 |
{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
|
1759 |
{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
|
1760 |
{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
|
1761 |
{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
|
1762 |
{CE_UINT8, 0, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1, 1}, |
0 | 1763 |
}; |
1764 |
||
1765 |
||
1766 |
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
|
1767 |
{ 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
|
1768 |
{ 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
|
1769 |
{ 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
|
1770 |
{ 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
|
1771 |
{ WIDGETS_END}, |
0 | 1772 |
}; |
1773 |
||
1774 |
extern void DrawPlayerIcon(int p, int x, int y); |
|
1775 |
||
1776 |
static void CheatsWndProc(Window *w, WindowEvent *e) |
|
1777 |
{ |
|
1778 |
switch(e->event) { |
|
1779 |
case WE_PAINT: { |
|
1780 |
int clk = WP(w,def_d).data_1; |
|
1781 |
const CheatEntry *ce = &_cheats_ui[0]; |
|
1782 |
int32 val; |
|
1783 |
int x, y; |
|
1784 |
int i; |
|
1785 |
||
1786 |
DrawWindowWidgets(w); |
|
1787 |
||
1788 |
DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, 350); |
|
1789 |
||
1790 |
x=0; |
|
1791 |
y=45; |
|
1792 |
||
1793 |
for(i=0; i!=lengthof(_cheats_ui); i++,ce++) { |
|
2535 | 1794 |
DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, x + 5, y + 2); |
0 | 1795 |
|
1796 |
if (ce->type == CE_BOOL) { |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1935
diff
changeset
|
1797 |
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
|
1798 |
SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
0 | 1799 |
|
1800 |
} else if (ce->type == CE_CLICK) { |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1935
diff
changeset
|
1801 |
DrawFrameRect(x+20, y+1, x+30+9, y+9, 0, (WP(w,def_d).data_1 == i*2+1) ? FR_LOWERED : 0); |
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1935
diff
changeset
|
1802 |
if (i == 0) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1803 |
SetDParam64(0, (int64) 10000000); |
0 | 1804 |
else |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1805 |
SetDParam(0, false); |
0 | 1806 |
|
1807 |
} else { |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1935
diff
changeset
|
1808 |
DrawFrameRect(x+20, y+1, x+20+9, y+9, 3, clk == i*2+1 ? FR_LOWERED : 0); |
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1935
diff
changeset
|
1809 |
DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? FR_LOWERED : 0); |
0 | 1810 |
DrawStringCentered(x+25, y+1, STR_6819, 0); |
1811 |
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
|
1812 |
|
0 | 1813 |
val = ReadCE(ce); |
100 | 1814 |
|
1815 |
// set correct string for switch climate cheat |
|
1816 |
if(ce->str==STR_CHEAT_SWITCH_CLIMATE) |
|
1817 |
val += STR_TEMPERATE_LANDSCAPE; |
|
1818 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1819 |
SetDParam(0, val); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1820 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1821 |
// display date for change date cheat |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1822 |
if(ce->str==STR_CHEAT_CHANGE_DATE) |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1823 |
SetDParam(0, _date); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1824 |
|
0 | 1825 |
// draw colored flag for change player cheat |
1826 |
if(ce->str==STR_CHEAT_CHANGE_PLAYER) |
|
1827 |
DrawPlayerIcon(_current_player, 156, y+2); |
|
1828 |
||
1829 |
} |
|
1830 |
||
1831 |
DrawString(50, y+1, ce->str, 0); |
|
1832 |
||
1833 |
y+=12; |
|
1834 |
} |
|
1835 |
break; |
|
1836 |
} |
|
1837 |
case WE_CLICK: { |
|
1838 |
const CheatEntry *ce; |
|
1839 |
uint btn = (e->click.pt.y - 46) / 12; |
|
1840 |
int32 val, oval; |
|
1841 |
uint x = e->click.pt.x; |
|
1842 |
||
1843 |
// not clicking a button? |
|
1844 |
if(!IS_INT_INSIDE(x, 20, 40) || btn>=lengthof(_cheats_ui)) |
|
1845 |
break; |
|
1846 |
||
1847 |
ce = &_cheats_ui[btn]; |
|
1848 |
oval = val = ReadCE(ce); |
|
1849 |
||
1850 |
*ce->been_used = true; |
|
1851 |
||
1852 |
switch(ce->type) { |
|
1853 |
case CE_BOOL: { |
|
1854 |
val ^= 1; |
|
1855 |
if (ce->click_proc != NULL) |
|
1856 |
ce->click_proc(val, 0); |
|
1857 |
break; |
|
1858 |
} |
|
1859 |
||
1860 |
case CE_CLICK: { |
|
1861 |
ce->click_proc(val, 0); |
|
1862 |
WP(w,def_d).data_1 = btn * 2 + 1; |
|
1863 |
break; |
|
1864 |
} |
|
1865 |
||
1866 |
default: { |
|
1867 |
if (x >= 30) { |
|
1868 |
//increase |
|
1869 |
val += ce->step; |
|
1870 |
if (val > ce->max) val = ce->max; |
|
1871 |
} else { |
|
1872 |
// decrease |
|
1873 |
val -= ce->step; |
|
1874 |
if (val < ce->min) val = ce->min; |
|
1875 |
} |
|
1876 |
||
1877 |
// take whatever the function returns |
|
1878 |
val = ce->click_proc(val, (x>=30) ? 1 : -1); |
|
1879 |
||
1880 |
if (val != oval) |
|
1881 |
WP(w,def_d).data_1 = btn * 2 + 1 + ((x>=30) ? 1 : 0); |
|
1882 |
||
1883 |
break; |
|
1884 |
} |
|
1885 |
} |
|
1886 |
||
1887 |
if (val != oval) { |
|
1888 |
WriteCE(ce, val); |
|
1889 |
SetWindowDirty(w); |
|
1890 |
} |
|
1891 |
||
1892 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
1893 |
||
1894 |
SetWindowDirty(w); |
|
1895 |
} |
|
1896 |
break; |
|
1897 |
case WE_TIMEOUT: |
|
1898 |
WP(w,def_d).data_1 = 0; |
|
1899 |
SetWindowDirty(w); |
|
1900 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1901 |
} |
0 | 1902 |
} |
1903 |
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
|
1904 |
240, 22, 400, 160, |
0 | 1905 |
WC_CHEATS,0, |
1906 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1907 |
_cheat_widgets, |
|
1908 |
CheatsWndProc |
|
1909 |
}; |
|
1910 |
||
1911 |
||
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
|
1912 |
void ShowCheatWindow(void) |
0 | 1913 |
{ |
1914 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1915 |
|
0 | 1916 |
DeleteWindowById(WC_CHEATS, 0); |
1917 |
w = AllocateWindowDesc(&_cheats_desc); |
|
1918 |
||
2549 | 1919 |
if (w != NULL) SetWindowDirty(w); |
0 | 1920 |
} |