author | tron |
Tue, 08 Feb 2005 16:37:28 +0000 | |
changeset 1344 | 53e040e3990d |
parent 1341 | 3533880da5d5 |
child 1345 | 5cb0e0eda22d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1274
diff
changeset
|
3 |
#include "debug.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
|
4 |
#include "strings.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
485
diff
changeset
|
5 |
#include "table/strings.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
|
6 |
#include "map.h" |
0 | 7 |
#include "window.h" |
8 |
#include "gui.h" |
|
9 |
#include "viewport.h" |
|
10 |
#include "gfx.h" |
|
11 |
#include "station.h" |
|
12 |
#include "command.h" |
|
13 |
#include "player.h" |
|
14 |
#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
|
15 |
#include "sound.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
16 |
#include "network.h" |
0 | 17 |
|
1341
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
18 |
// Windows stuff for Clipboard |
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
19 |
#if defined(WIN32) |
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
20 |
#include <windows.h> |
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
21 |
#endif |
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
22 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
23 |
#include "hal.h" // for file list |
0 | 24 |
|
25 |
bool _query_string_active; |
|
26 |
||
596
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
27 |
/* Now this is what I call dirty.. the edit-box needs to be rewritten! */ |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
28 |
static bool _do_edit_on_text_even_when_no_change_to_edit_box; |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
29 |
|
0 | 30 |
typedef struct LandInfoData { |
31 |
Town *town; |
|
32 |
int32 costclear; |
|
33 |
AcceptedCargo ac; |
|
34 |
uint tile; |
|
35 |
TileDesc td; |
|
36 |
} LandInfoData; |
|
37 |
||
38 |
static void LandInfoWndProc(Window *w, WindowEvent *e) |
|
39 |
{ |
|
40 |
LandInfoData *lid; |
|
41 |
StringID str; |
|
42 |
||
43 |
if (e->event == WE_PAINT) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
44 |
int idx = 0; |
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
45 |
int i; |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
46 |
|
0 | 47 |
DrawWindowWidgets(w); |
48 |
||
49 |
lid = WP(w,void_d).data; |
|
50 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
51 |
SetDParam(0, lid->td.dparam[0]); |
0 | 52 |
DrawStringCentered(140, 16, lid->td.str, 13); |
53 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
54 |
SetDParam(0, STR_01A6_N_A); |
0 | 55 |
if (lid->td.owner != OWNER_NONE && lid->td.owner != OWNER_WATER) |
56 |
GetNameOfOwner(lid->td.owner, lid->tile); |
|
57 |
DrawStringCentered(140, 27, STR_01A7_OWNER, 0); |
|
58 |
||
59 |
str = STR_01A4_COST_TO_CLEAR_N_A; |
|
60 |
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
|
61 |
SetDParam(0, lid->costclear); |
0 | 62 |
str = STR_01A5_COST_TO_CLEAR; |
63 |
} |
|
64 |
DrawStringCentered(140, 38, str, 0); |
|
65 |
||
485
453c096beb1b
(svn r767) Introduce USERSTRING_LEN (128) and try to make sure we don't overflow it anywhere (as long as we keep USERSTRING_LEN above 7 or so).
pasky
parents:
473
diff
changeset
|
66 |
snprintf(_userstring, USERSTRING_LEN, "%.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
|
67 |
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
|
68 |
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
|
69 |
SetDParam(2, STR_SPEC_USERSTRING); |
0 | 70 |
DrawStringCentered(140, 49, STR_LANDINFO_COORDS, 0); |
71 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
72 |
SetDParam(0, STR_01A9_NONE); |
0 | 73 |
if (lid->town != NULL) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
74 |
SetDParam(0, lid->town->townnametype); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
75 |
SetDParam(1, lid->town->townnameparts); |
0 | 76 |
} |
77 |
DrawStringCentered(140,60, STR_01A8_LOCAL_AUTHORITY, 0); |
|
78 |
||
79 |
str = STR_01CE_CARGO_ACCEPTED - 1; |
|
80 |
||
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
81 |
/* XXX if a tile accepts more cargo types than there are template strings |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
82 |
* this breaks */ |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
83 |
for (i = 0; i < NUM_CARGO; ++i) { |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
84 |
if (lid->ac[i] > 0) { |
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
85 |
if (lid->ac[i] < 8) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
86 |
SetDParam(idx++, STR_01D1_8); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
87 |
SetDParam(idx++, lid->ac[i]); |
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
88 |
} |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
89 |
SetDParam(idx++, _cargoc.names_s[i]); |
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
90 |
str++; |
0 | 91 |
} |
92 |
} |
|
93 |
||
94 |
if (str != (STR_01CE_CARGO_ACCEPTED - 1)) |
|
95 |
DrawStringMultiCenter(140, 76, str, 276); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
96 |
|
71
1b8e15a10515
(svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents:
70
diff
changeset
|
97 |
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
|
98 |
SetDParam(0,lid->td.build_date); |
71
1b8e15a10515
(svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents:
70
diff
changeset
|
99 |
DrawStringCentered(140,71, STR_BUILD_DATE, 0); |
1b8e15a10515
(svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents:
70
diff
changeset
|
100 |
} |
0 | 101 |
} |
102 |
} |
|
103 |
||
104 |
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
|
105 |
{ 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
|
106 |
{ 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
|
107 |
{ 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
|
108 |
{ WIDGETS_END}, |
0 | 109 |
}; |
110 |
||
111 |
static const WindowDesc _land_info_desc = { |
|
112 |
-1, -1, 280, 93, |
|
113 |
WC_LAND_INFO,0, |
|
114 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
115 |
_land_info_widgets, |
|
116 |
LandInfoWndProc |
|
117 |
}; |
|
118 |
||
119 |
static void Place_LandInfo(uint tile) |
|
120 |
{ |
|
121 |
Player *p; |
|
122 |
static LandInfoData lid; |
|
123 |
Window *w; |
|
124 |
int64 old_money; |
|
125 |
||
126 |
DeleteWindowById(WC_LAND_INFO, 0); |
|
127 |
||
128 |
w = AllocateWindowDesc(&_land_info_desc); |
|
129 |
WP(w,void_d).data = &lid; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
130 |
|
0 | 131 |
lid.tile = tile; |
132 |
lid.town = ClosestTownFromTile(tile, _patches.dist_local_authority); |
|
133 |
||
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
134 |
if (_local_player >= MAX_PLAYERS) |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
135 |
p = DEREF_PLAYER(0); |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
136 |
else |
0 | 137 |
p = DEREF_PLAYER(_local_player); |
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
138 |
|
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
139 |
old_money = p->money64; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
140 |
p->money64 = p->player_money = 0x7fffffff; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
141 |
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
|
142 |
p->money64 = old_money; |
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
143 |
UpdatePlayerMoney32(p); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
144 |
|
71
1b8e15a10515
(svn r72) -Add: build_date of station (viewable with Query tool)
truelight
parents:
70
diff
changeset
|
145 |
// 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
|
146 |
lid.td.build_date = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
147 |
|
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
410
diff
changeset
|
148 |
GetAcceptedCargo(tile, lid.ac); |
0 | 149 |
GetTileDesc(tile, &lid.td); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
150 |
|
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
151 |
#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
|
152 |
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
|
153 |
DEBUG(misc, 0) ("TILE: %d ", tile); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
154 |
DEBUG(misc, 0) ("_map_type_and_height=%#x", _map_type_and_height[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
155 |
DEBUG(misc, 0) ("_map2=%#x", _map2[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
156 |
DEBUG(misc, 0) ("_map3_lo=%#x", _map3_lo[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
157 |
DEBUG(misc, 0) ("_map3_hi=%#x", _map3_hi[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
158 |
DEBUG(misc, 0) ("_map5=%#x", _map5[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
159 |
DEBUG(misc, 0) ("_map_owner=%#x", _map_owner[tile]); |
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
3
diff
changeset
|
160 |
#endif |
0 | 161 |
} |
162 |
||
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
|
163 |
void PlaceLandBlockInfo(void) |
0 | 164 |
{ |
165 |
if (_cursor.sprite == 0x2CF) { |
|
166 |
ResetObjectToPlace(); |
|
167 |
} else { |
|
168 |
_place_proc = Place_LandInfo; |
|
169 |
SetObjectToPlace(0x2CF, 1, 1, 0); |
|
170 |
} |
|
171 |
} |
|
172 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
173 |
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
|
174 |
/************************************************************************* |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
175 |
* 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
|
176 |
"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
|
177 |
"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
|
178 |
"", |
1124 | 179 |
"The OpenTTD team (in alphabetical order):", |
180 |
" Bjarni Corfitzen (Bjarni) - MacOS port", |
|
1125 | 181 |
" Victor Fischer (Celestar) - Programming everywhere you need him to", |
1124 | 182 |
" Tamas Faragó (Darkvater) - Lead coder", |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
183 |
" Dominik Scherer (dominik81) - Lead coder", |
1124 | 184 |
" 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
|
185 |
" Owen Rudge (orudge) - Forum- and masterserver host, OS/2 port", |
1126 | 186 |
" Christoph Mallon (Tron) - Programmer, code correctness police", |
1124 | 187 |
" Patric Stout (TrueLight) - Coder, network guru, SVN- and website host", |
1125 | 188 |
"", |
189 |
"Retired Developers:", |
|
190 |
" 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
|
191 |
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
192 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
193 |
"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
|
194 |
" 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
|
195 |
" Marcin Grzegorczyk - For his documentation of TTD internals", |
1125 | 196 |
" blathijs - For his many patches, suggestions and major work on maprewrite", |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
197 |
" pasky - Many patches, newgrf support", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
198 |
" Stefan Meißner (sign_de) - For his work on the console", |
1124 | 199 |
" Cian Duffy (MYOB) - BeOS port / manual writing", |
200 |
" 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
|
201 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
202 |
" 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
|
203 |
" 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
|
204 |
" 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
|
205 |
" 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
|
206 |
" 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
|
207 |
NULL, |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
208 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
209 |
"", |
1124 | 210 |
"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
|
211 |
" 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
|
212 |
}; |
0 | 213 |
|
214 |
static void AboutWindowProc(Window *w, WindowEvent *e) |
|
215 |
{ |
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
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
|
220 |
break; |
0 | 221 |
case WE_PAINT: { |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
222 |
const char *str; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
223 |
char buffer[100]; |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
224 |
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
|
225 |
int y = WP(w, scroller_d).height; |
0 | 226 |
DrawWindowWidgets(w); |
227 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
228 |
// Show original copyright and revision version |
1125 | 229 |
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0); |
230 |
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
|
231 |
|
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
232 |
// 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
|
233 |
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
|
234 |
if (y >= 50 && y < (w->height - 40)) { |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
235 |
str = credits[i]; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
236 |
/* Hack-Alert: Translated by is a dynamic string as it changes |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
237 |
* with the language chosen. So the special value of NULL is used |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
238 |
* to identify this for the moment */ |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
239 |
if (str == NULL) { |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
240 |
GetString(buffer, STR_TRANSLATED_BY); |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
241 |
str = buffer; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
242 |
} |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
243 |
|
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
244 |
DoDrawString(str, 10, y, 0x10); |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
245 |
} |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
246 |
y += 10; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
247 |
} |
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 |
// 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
|
250 |
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
|
251 |
|
1125 | 252 |
DrawStringMultiCenter(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, 398); |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
253 |
} break; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
SetWindowDirty(w); |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
258 |
} |
0 | 259 |
break; |
260 |
} |
|
261 |
} |
|
262 |
||
263 |
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
|
264 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
1125 | 265 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
266 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
|
267 |
{ 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
|
268 |
{ WIDGETS_END}, |
0 | 269 |
}; |
270 |
||
271 |
static const WindowDesc _about_desc = { |
|
1125 | 272 |
WDP_CENTER, WDP_CENTER, 420, 272, |
0 | 273 |
WC_GAME_OPTIONS,0, |
274 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
275 |
_about_widgets, |
|
276 |
AboutWindowProc |
|
277 |
}; |
|
278 |
||
279 |
||
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
|
280 |
void ShowAboutWindow(void) |
0 | 281 |
{ |
282 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
283 |
AllocateWindowDesc(&_about_desc); |
|
284 |
} |
|
285 |
||
286 |
static int _tree_to_plant; |
|
287 |
||
288 |
static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32}; |
|
289 |
static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9}; |
|
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, |
|
294 |
0x79E,0x30D87A5,0x30B87AC,0x7B3,0x7BA,0x30B87C1,0x30887C8,0x30A87CF,0x30B87D6 |
|
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 |
|
0 | 334 |
if (HandlePlacePushButton(w, wid, 0x7DA, 1, NULL)) |
335 |
_tree_to_plant = WP(w,tree_d).base + wid - 3; |
|
336 |
break; |
|
337 |
||
338 |
case 15: // tree of random type. |
|
339 |
if (HandlePlacePushButton(w, 15, 0x7DA, 1, NULL)) |
|
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 |
{ |
440 |
AllocateWindowDesc(&_build_trees_desc); |
|
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 { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
487 |
Player *p = DEREF_PLAYER(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: { |
|
513 |
TileHighlightData *thd = _thd_ptr; |
|
514 |
TileIndex tile = thd->redsq; |
|
515 |
thd->redsq = 0; |
|
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
155
diff
changeset
|
516 |
_switch_mode_errorstr = INVALID_STRING_ID; |
0 | 517 |
if (tile != 0) |
518 |
MarkTileDirtyByTile(tile); |
|
519 |
break; |
|
520 |
} |
|
521 |
||
522 |
case WE_KEYPRESS: |
|
523 |
if (e->keypress.keycode == WKC_SPACE) { |
|
524 |
// Don't continue. |
|
525 |
e->keypress.cont = false; |
|
526 |
DeleteWindow(w); |
|
527 |
} |
|
528 |
break; |
|
529 |
} |
|
530 |
} |
|
531 |
||
532 |
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) |
|
533 |
{ |
|
534 |
Window *w; |
|
535 |
ViewPort *vp; |
|
536 |
Point pt; |
|
537 |
||
538 |
DeleteWindowById(WC_ERRMSG, 0); |
|
539 |
||
540 |
//assert(msg_2); |
|
541 |
if (msg_2 == 0) msg_2 = STR_EMPTY; |
|
542 |
||
543 |
_errmsg_message_1 = msg_1; |
|
544 |
_errmsg_message_2 = msg_2; |
|
545 |
COPY_OUT_DPARAM(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); |
|
546 |
_errmsg_duration = _patches.errmsg_duration; |
|
547 |
if (!_errmsg_duration) |
|
548 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
549 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
550 |
if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) { |
0 | 551 |
|
552 |
if ( (x|y) != 0) { |
|
553 |
pt = RemapCoords2(x, y); |
|
554 |
for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {} |
|
555 |
vp = w->viewport; |
|
556 |
||
557 |
// move x pos to opposite corner |
|
558 |
pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left; |
|
559 |
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
|
560 |
|
0 | 561 |
// move y pos to opposite corner |
562 |
pt.y = ((pt.y - vp->virtual_top) >> vp->zoom) + vp->top; |
|
563 |
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
|
564 |
|
0 | 565 |
} else { |
566 |
pt.x = (_screen.width - 240) >> 1; |
|
567 |
pt.y = (_screen.height - 46) >> 1; |
|
568 |
} |
|
569 |
w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
|
570 |
} else { |
|
571 |
if ( (x|y) != 0) { |
|
572 |
pt = RemapCoords2(x, y); |
|
573 |
for(w=_windows; w->window_class != WC_MAIN_WINDOW; w++) {} |
|
574 |
vp = w->viewport; |
|
575 |
pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
|
576 |
pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
|
577 |
} else { |
|
578 |
pt.x = (_screen.width - 334) >> 1; |
|
579 |
pt.y = (_screen.height - 137) >> 1; |
|
580 |
} |
|
581 |
w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
|
582 |
} |
|
583 |
||
584 |
w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
|
585 |
} |
|
586 |
||
587 |
||
588 |
void ShowEstimatedCostOrIncome(int32 cost, int x, int y) |
|
589 |
{ |
|
590 |
int msg = STR_0805_ESTIMATED_COST; |
|
591 |
||
592 |
if (cost < 0) { |
|
593 |
cost = -cost; |
|
594 |
msg = STR_0807_ESTIMATED_INCOME; |
|
595 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
596 |
SetDParam(0, cost); |
0 | 597 |
ShowErrorMessage(-1, msg, x, y); |
598 |
} |
|
599 |
||
600 |
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost) |
|
601 |
{ |
|
602 |
int msg; |
|
603 |
Point pt = RemapCoords(x,y,z); |
|
604 |
||
605 |
msg = STR_0801_COST; |
|
606 |
if (cost < 0) { |
|
607 |
cost = -cost; |
|
608 |
msg = STR_0803_INCOME; |
|
609 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
610 |
SetDParam(0, cost); |
0 | 611 |
AddTextEffect(msg, pt.x, pt.y, 0x250); |
612 |
} |
|
613 |
||
614 |
static Widget _tooltips_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
615 |
{ 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
|
616 |
{ WIDGETS_END}, |
0 | 617 |
}; |
618 |
||
619 |
||
620 |
static void TooltipsWndProc(Window *w, WindowEvent *e) |
|
621 |
{ |
|
622 |
||
623 |
switch(e->event) { |
|
624 |
case WE_PAINT: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
625 |
GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
0 | 626 |
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
627 |
DrawStringMultiCenter((w->width>>1), (w->height>>1)-5, WP(w,tooltips_d).string_id, 197); |
|
628 |
break; |
|
629 |
} |
|
630 |
case WE_MOUSELOOP: |
|
631 |
if (!_right_button_down) |
|
632 |
DeleteWindow(w); |
|
633 |
break; |
|
634 |
} |
|
635 |
} |
|
636 |
||
637 |
void GuiShowTooltips(StringID string_id) |
|
638 |
{ |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
639 |
char buffer[512]; |
0 | 640 |
Window *w; |
641 |
int right,bottom; |
|
642 |
int x,y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
643 |
|
0 | 644 |
if (string_id == 0) |
645 |
return; |
|
646 |
||
647 |
w = FindWindowById(WC_TOOLTIPS, 0); |
|
648 |
if (w != NULL) { |
|
649 |
if (WP(w,tooltips_d).string_id == string_id) |
|
650 |
return; |
|
651 |
DeleteWindow(w); |
|
652 |
} |
|
653 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
654 |
GetString(buffer, string_id); |
0 | 655 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
656 |
right = GetStringWidth(buffer) + 4; |
0 | 657 |
|
658 |
bottom = 14; |
|
659 |
if (right > 200) { |
|
660 |
bottom += ((right - 4) / 176) * 10; |
|
661 |
right = 200; |
|
662 |
} |
|
663 |
||
664 |
_tooltips_widgets[0].right = right; |
|
665 |
_tooltips_widgets[0].bottom = bottom; |
|
666 |
||
667 |
y = _cursor.pos.y + 30; |
|
668 |
if (y < 22) y = 22; |
|
669 |
||
670 |
if (y > (_screen.height - 44) && (y-=52) > (_screen.height - 44)) |
|
671 |
y = (_screen.height - 44); |
|
672 |
||
673 |
x = _cursor.pos.x - (right >> 1); |
|
674 |
if (x < 0) x = 0; |
|
675 |
if (x > (_screen.width - right)) x = _screen.width - right; |
|
676 |
||
677 |
w = AllocateWindow(x, y, right, bottom, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
|
678 |
WP(w,tooltips_d).string_id = string_id; |
|
679 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
|
680 |
} |
|
681 |
||
682 |
||
683 |
static void DrawStationCoverageText(const uint *accepts, int str_x, int str_y, uint mask) |
|
684 |
{ |
|
685 |
int i; |
|
1329 | 686 |
char *b; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
687 |
|
0 | 688 |
b = _userstring; |
689 |
b[0] = 0x81; |
|
690 |
b[1] = STR_000D_ACCEPTS; |
|
691 |
b[2] = STR_000D_ACCEPTS >> 8; |
|
692 |
b += 3; |
|
693 |
||
694 |
for(i=0; i!=NUM_CARGO; i++,mask>>=1) { |
|
695 |
if (accepts[i] >= 8 && (mask&1) ) { |
|
696 |
StringID id = _cargoc.names_s[i]; |
|
697 |
b[0] = 0x81; |
|
698 |
b[1] = (byte)(id & 255); |
|
699 |
b[2] = (byte)(id >> 8); |
|
700 |
b[3] = ','; |
|
701 |
b[4] = ' '; |
|
702 |
b += 5; |
|
703 |
} |
|
704 |
} |
|
705 |
||
1329 | 706 |
if (b == &_userstring[3]) { |
0 | 707 |
b[0] = 0x81; |
1341
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
708 |
b[1] = (char)STR_00D0_NOTHING; |
0 | 709 |
b[2] = STR_00D0_NOTHING >> 8; |
710 |
b[3] = 0; |
|
711 |
} else { |
|
712 |
b[-2] = 0; |
|
713 |
} |
|
714 |
||
715 |
DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
|
716 |
} |
|
717 |
||
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
718 |
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) { |
0 | 719 |
int x = _thd.pos.x; |
720 |
int y = _thd.pos.y; |
|
721 |
uint accepts[NUM_CARGO]; |
|
722 |
if (x != -1) { |
|
980
4d1b8af9866b
(svn r1476) -Fix: [1099209] Catchment area with drag&drop stations (Celestar)
darkvater
parents:
959
diff
changeset
|
723 |
GetAcceptanceAroundTiles(accepts, TILE_FROM_XY(x, y), _thd.size.x /16, _thd.size.y /16 , rad); |
0 | 724 |
DrawStationCoverageText(accepts, sx, sy, mask); |
725 |
} |
|
726 |
} |
|
727 |
||
728 |
void CheckRedrawStationCoverage(Window *w) |
|
729 |
{ |
|
730 |
if (_thd.dirty&1) { |
|
731 |
_thd.dirty&=~1; |
|
732 |
SetWindowDirty(w); |
|
733 |
} |
|
734 |
} |
|
735 |
||
736 |
||
737 |
void UnclickSomeWindowButtons(Window *w, uint32 mask) |
|
738 |
{ |
|
739 |
uint32 x = w->click_state & mask; |
|
740 |
int i = 0; |
|
741 |
w->click_state ^= x; |
|
742 |
do { |
|
743 |
if (x&1) InvalidateWidget(w,i); |
|
744 |
} while(i++,x>>=1); |
|
745 |
} |
|
746 |
||
747 |
||
748 |
void UnclickWindowButtons(Window *w) |
|
749 |
{ |
|
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
|
750 |
bool sticky = false; |
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
|
751 |
if (w->desc_flags & WDF_STICKY_BUTTON && HASBIT(w->click_state, 2)) sticky = true; |
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
|
752 |
|
0 | 753 |
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
|
754 |
|
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
|
755 |
if (sticky) SETBIT(w->click_state, 2); |
0 | 756 |
} |
757 |
||
758 |
||
759 |
void SetVScrollCount(Window *w, int num) |
|
760 |
{ |
|
761 |
w->vscroll.count = num; |
|
762 |
num -= w->vscroll.cap; |
|
763 |
if (num < 0) num = 0; |
|
764 |
if (num < w->vscroll.pos) w->vscroll.pos = num; |
|
765 |
} |
|
766 |
||
842 | 767 |
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
|
768 |
{ |
842 | 769 |
w->vscroll2.count = num; |
770 |
num -= w->vscroll2.cap; |
|
771 |
if (num < 0) num = 0; |
|
772 |
if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
|
773 |
} |
|
774 |
||
0 | 775 |
void SetHScrollCount(Window *w, int num) |
776 |
{ |
|
777 |
w->hscroll.count = num; |
|
778 |
num -= w->hscroll.cap; |
|
779 |
if (num < 0) num = 0; |
|
780 |
if (num < w->hscroll.pos) w->hscroll.pos = num; |
|
781 |
} |
|
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 |
/* Get the count of characters in the string as well as the width in pixels |
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
|
784 |
* [IN]buf: string to be checked |
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
|
785 |
* [OUT]count: gets set to the count of characters |
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
|
786 |
* [OUT]width: gets set to the pixels width */ |
1329 | 787 |
static void GetCurrentStringSize(const char *buf, int *count, int *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
|
788 |
{ |
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
|
789 |
*count = 0; |
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
|
790 |
*width = -1; |
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
|
791 |
|
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
|
792 |
do { |
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
|
793 |
if (*++buf == 0) |
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
|
794 |
break; |
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
|
795 |
(*count)++; |
1329 | 796 |
(*width) += _stringwidth_table[(byte)*buf - 32]; |
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
|
797 |
} while (1); |
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
|
798 |
} |
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
|
799 |
|
0 | 800 |
int HandleEditBoxKey(Window *w, int wid, WindowEvent *we) |
801 |
{ |
|
802 |
int width,count; |
|
803 |
int key = we->keypress.ascii; |
|
804 |
||
805 |
we->keypress.cont = false; |
|
806 |
||
807 |
if (we->keypress.keycode == WKC_ESC) { |
|
808 |
return 2; |
|
809 |
} else if (we->keypress.keycode == WKC_RETURN) { |
|
810 |
return 1; |
|
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
|
811 |
#ifdef WIN32 |
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
|
812 |
} else if (we->keypress.keycode == (WKC_CTRL | 'V')) { |
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
|
813 |
if (IsClipboardFormatAvailable(CF_TEXT)) { |
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
|
814 |
const byte* data; |
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
|
815 |
HGLOBAL cbuf; |
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
|
816 |
|
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
|
817 |
OpenClipboard(NULL); |
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
|
818 |
cbuf = GetClipboardData(CF_TEXT); |
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
|
819 |
data = GlobalLock(cbuf); // clipboard data |
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
|
820 |
|
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
|
821 |
GetCurrentStringSize(WP(w,querystr_d).buf - 1, &count, &width); |
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
|
822 |
|
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
|
823 |
/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */ |
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
|
824 |
for (; (IS_INT_INSIDE(*data, ' ', 256)) && // valid ASCII char |
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
|
825 |
(count < WP(w,querystr_d).maxlen - 1 && // max charcount; always allow for terminating '\0' |
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
|
826 |
width + _stringwidth_table[(int)(*data) - 32] <= WP(w,querystr_d).maxwidth); ++data) { // max screensize |
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
|
827 |
|
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
|
828 |
// append data and update size parameters |
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
|
829 |
WP(w,querystr_d).buf[count] = *data; |
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
|
830 |
count++; |
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
|
831 |
width += _stringwidth_table[*data - 32]; |
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
|
832 |
} |
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
|
833 |
WP(w,querystr_d).buf[count + 1] = '\0'; |
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
|
834 |
|
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
|
835 |
GlobalUnlock(cbuf); |
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
|
836 |
CloseClipboard(); |
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
|
837 |
InvalidateWidget(w, wid); |
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
|
838 |
} |
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
|
839 |
#endif |
0 | 840 |
} else { |
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
|
841 |
GetCurrentStringSize(WP(w,querystr_d).buf - 1, &count, &width); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
842 |
|
0 | 843 |
if (we->keypress.keycode == WKC_BACKSPACE) { |
844 |
if (count != 0) { |
|
845 |
WP(w,querystr_d).buf[count-1] = 0; |
|
846 |
InvalidateWidget(w, wid); |
|
847 |
} |
|
848 |
} else if (IS_INT_INSIDE((key = we->keypress.ascii), 32, 256)) { |
|
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
|
849 |
if (count < WP(w,querystr_d).maxlen && width + _stringwidth_table[key - 32] <= WP(w,querystr_d).maxwidth) { |
0 | 850 |
WP(w,querystr_d).buf[count] = key; |
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
|
851 |
WP(w,querystr_d).buf[count + 1] = '\0'; |
0 | 852 |
InvalidateWidget(w, wid); |
853 |
} |
|
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
|
854 |
} else // key wasn't caught |
0 | 855 |
we->keypress.cont = true; |
856 |
} |
|
857 |
||
858 |
return 0; |
|
859 |
} |
|
860 |
||
861 |
void HandleEditBox(Window *w, int wid) |
|
862 |
{ |
|
863 |
bool b; |
|
864 |
||
865 |
/* caret changed? */ |
|
866 |
b = !!(_caret_timer & 0x20); |
|
867 |
if (b != WP(w,querystr_d).caret) { |
|
868 |
WP(w,querystr_d).caret = b; |
|
869 |
InvalidateWidget(w, wid); |
|
870 |
} |
|
871 |
} |
|
872 |
||
873 |
void DrawEditBox(Window *w, int wid) |
|
874 |
{ |
|
875 |
const Widget *wi = w->widget + wid; |
|
876 |
int x; |
|
877 |
||
878 |
GfxFillRect(wi->left+1, wi->top+1, wi->right-1, wi->bottom-1, 215); |
|
879 |
x = DoDrawString(WP(w,querystr_d).buf, wi->left+2, wi->top+1, 8); |
|
880 |
if (WP(w,querystr_d).caret) |
|
881 |
DoDrawString("_", x, wi->top+1, 12); |
|
882 |
} |
|
883 |
||
884 |
||
885 |
#define MAX_QUERYSTR_LEN 64 |
|
886 |
||
887 |
static void QueryStringWndProc(Window *w, WindowEvent *e) |
|
888 |
{ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
889 |
static bool closed = false; |
0 | 890 |
switch(e->event) { |
891 |
case WE_PAINT: { |
|
892 |
// int x; |
|
893 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
894 |
SetDParam(0, WP(w,querystr_d).caption); |
0 | 895 |
DrawWindowWidgets(w); |
896 |
||
897 |
DrawEditBox(w, 5); |
|
898 |
} break; |
|
899 |
||
900 |
case WE_CLICK: |
|
901 |
switch(e->click.widget) { |
|
902 |
case 3: DeleteWindow(w); break; |
|
903 |
case 4: |
|
904 |
press_ok:; |
|
1304
8570010abe7b
(svn r1808) Use strcmp() instead of home brewed function str_eq()
tron
parents:
1299
diff
changeset
|
905 |
if (strcmp(WP(w,querystr_d).buf, WP(w,querystr_d).buf + MAX_QUERYSTR_LEN) == 0 && |
8570010abe7b
(svn r1808) Use strcmp() instead of home brewed function str_eq()
tron
parents:
1299
diff
changeset
|
906 |
!_do_edit_on_text_even_when_no_change_to_edit_box) { |
0 | 907 |
DeleteWindow(w); |
908 |
} else { |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
909 |
char *buf = WP(w,querystr_d).buf; |
390
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
910 |
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
|
911 |
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
|
912 |
Window *parent; |
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
913 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
914 |
// 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
|
915 |
closed = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
916 |
|
598
200de7111fa9
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
917 |
DeleteWindow(w); |
200de7111fa9
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
918 |
|
390
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
919 |
parent = FindWindowById(wnd_class, wnd_num); |
0 | 920 |
if (parent != NULL) { |
921 |
WindowEvent e; |
|
922 |
e.event = WE_ON_EDIT_TEXT; |
|
923 |
e.edittext.str = buf; |
|
924 |
parent->wndproc(parent, &e); |
|
925 |
} |
|
926 |
} |
|
927 |
break; |
|
928 |
} |
|
929 |
break; |
|
930 |
||
931 |
case WE_MOUSELOOP: { |
|
932 |
if (!FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num)) { |
|
933 |
DeleteWindow(w); |
|
934 |
return; |
|
935 |
} |
|
936 |
HandleEditBox(w, 5); |
|
937 |
} break; |
|
938 |
||
939 |
case WE_KEYPRESS: { |
|
940 |
switch(HandleEditBoxKey(w, 5, e)) { |
|
941 |
case 1: // Return |
|
942 |
goto press_ok; |
|
943 |
case 2: // Escape |
|
944 |
DeleteWindow(w); |
|
945 |
break; |
|
946 |
} |
|
947 |
} break; |
|
948 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
949 |
case WE_CREATE: |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
950 |
closed = false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
951 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
952 |
|
0 | 953 |
case WE_DESTROY: |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
954 |
// 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
|
955 |
if (!closed) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
956 |
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
|
957 |
if (parent != NULL) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
958 |
WindowEvent e; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
959 |
e.event = WE_ON_EDIT_TEXT_CANCEL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
960 |
parent->wndproc(parent, &e); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
961 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
962 |
} |
0 | 963 |
_query_string_active = false; |
964 |
break; |
|
965 |
} |
|
966 |
} |
|
967 |
||
968 |
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
|
969 |
{ 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
|
970 |
{ 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
|
971 |
{ 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
|
972 |
{ 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
|
973 |
{ 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
|
974 |
{ 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
|
975 |
{ WIDGETS_END}, |
0 | 976 |
}; |
977 |
||
978 |
static const WindowDesc _query_string_desc = { |
|
979 |
190, 219, 260, 42, |
|
980 |
WC_QUERY_STRING,0, |
|
981 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
982 |
_query_string_widgets, |
|
983 |
QueryStringWndProc |
|
984 |
}; |
|
985 |
||
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
986 |
static char _edit_str_buf[MAX_QUERYSTR_LEN*2]; |
0 | 987 |
|
988 |
void ShowQueryString(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number) |
|
989 |
{ |
|
990 |
Window *w; |
|
991 |
||
992 |
#define _orig_edit_str_buf (_edit_str_buf+MAX_QUERYSTR_LEN) |
|
993 |
||
994 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
995 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
996 |
||
1344
53e040e3990d
(svn r1848) Remove the obscure feature of initialising the edit box with the contents of str_buffr - it was unused anyway.
tron
parents:
1341
diff
changeset
|
997 |
GetString(_orig_edit_str_buf, str); |
596
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
998 |
|
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
999 |
if (maxlen & 0x1000) { |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1000 |
_do_edit_on_text_even_when_no_change_to_edit_box = true; |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1001 |
maxlen &= ~0x1000; |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1002 |
} else |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1003 |
_do_edit_on_text_even_when_no_change_to_edit_box = false; |
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1004 |
|
0 | 1005 |
_orig_edit_str_buf[maxlen] = 0; |
1006 |
||
1007 |
memcpy(_edit_str_buf, _orig_edit_str_buf, MAX_QUERYSTR_LEN); |
|
1008 |
||
1009 |
w = AllocateWindowDesc(&_query_string_desc); |
|
1010 |
||
1011 |
w->click_state = 1 << 5; |
|
1012 |
WP(w,querystr_d).caption = caption; |
|
1013 |
WP(w,querystr_d).wnd_class = window_class; |
|
1014 |
WP(w,querystr_d).wnd_num = window_number; |
|
1015 |
WP(w,querystr_d).caret = 0; |
|
1016 |
WP(w,querystr_d).maxlen = maxlen; |
|
1017 |
WP(w,querystr_d).maxwidth = maxwidth; |
|
1018 |
WP(w,querystr_d).buf = _edit_str_buf; |
|
1019 |
||
1020 |
_query_string_active = true; |
|
1021 |
} |
|
1022 |
||
1023 |
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
|
1024 |
{ 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
|
1025 |
{ 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
|
1026 |
{ 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
|
1027 |
{ 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
|
1028 |
{ 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
|
1029 |
{ 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
|
1030 |
{ WWT_6, RESIZE_RB, 14, 2, 243, 50, 291, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
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
|
1031 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 48, 281, 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
|
1032 |
{ 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
|
1033 |
{ WIDGETS_END}, |
0 | 1034 |
}; |
1035 |
||
1036 |
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
|
1037 |
{ 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
|
1038 |
{ 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
|
1039 |
{ 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
|
1040 |
{ 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
|
1041 |
{ 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
|
1042 |
{ 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
|
1043 |
{ WWT_6, RESIZE_RB, 14, 2, 243, 50, 291, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
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
|
1044 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 48, 281, 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
|
1045 |
{ 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
|
1046 |
{ WIDGETS_END}, |
0 | 1047 |
}; |
1048 |
||
1049 |
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
|
1050 |
{ 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
|
1051 |
{ 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
|
1052 |
{ 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
|
1053 |
{ 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
|
1054 |
{ 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
|
1055 |
{ 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
|
1056 |
{ WWT_6, RESIZE_RB, 14, 2, 243, 50, 290, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
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
|
1057 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 48, 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
|
1058 |
{ 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
|
1059 |
{ 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
|
1060 |
{ 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
|
1061 |
{ 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
|
1062 |
{ 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
|
1063 |
{ WIDGETS_END}, |
0 | 1064 |
}; |
1065 |
||
1066 |
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
|
1067 |
{ 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
|
1068 |
{ 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
|
1069 |
{ 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
|
1070 |
{ 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
|
1071 |
{ 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
|
1072 |
{ 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
|
1073 |
{ WWT_6, RESIZE_RB, 14, 2, 243, 50, 290, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
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
|
1074 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 48, 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
|
1075 |
{ 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
|
1076 |
{ 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
|
1077 |
{ 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
|
1078 |
{ 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
|
1079 |
{ 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
|
1080 |
{ WIDGETS_END}, |
0 | 1081 |
}; |
1082 |
||
1083 |
||
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
|
1084 |
void BuildFileList(void) |
0 | 1085 |
{ |
1086 |
FiosFreeSavegameList(); |
|
1087 |
if(_saveload_mode==SLD_NEW_GAME || _saveload_mode==SLD_LOAD_SCENARIO || _saveload_mode==SLD_SAVE_SCENARIO) |
|
1088 |
_fios_list = FiosGetScenarioList(&_fios_num, _saveload_mode); |
|
1089 |
else |
|
1090 |
_fios_list = FiosGetSavegameList(&_fios_num, _saveload_mode); |
|
1091 |
} |
|
1092 |
||
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
|
1093 |
static void DrawFiosTexts(void) |
0 | 1094 |
{ |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
193
diff
changeset
|
1095 |
const char *path; |
0 | 1096 |
StringID str; |
1097 |
||
1098 |
str = FiosGetDescText(&path); |
|
1099 |
if (str != 0) |
|
1100 |
DrawString(2, 37, str, 0); |
|
1101 |
DoDrawString(path, 2, 27, 16); |
|
1102 |
} |
|
1103 |
||
1104 |
#if defined(_WIN32) |
|
1105 |
extern int CDECL compare_FiosItems (const void *a, const void *b); |
|
1106 |
#else |
|
1107 |
extern int compare_FiosItems (const void *a, const void *b); |
|
1108 |
#endif |
|
1109 |
||
1110 |
||
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
|
1111 |
static void MakeSortedSaveGameList(void) |
0 | 1112 |
{ |
1113 |
/* Directories are always above the files (FIOS_TYPE_DIR) |
|
1114 |
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE) |
|
1115 |
* Only sort savegames/scenarios, not directories |
|
1116 |
*/ |
|
1117 |
||
1118 |
int i, sort_start, sort_end, s_amount; |
|
1119 |
i = sort_start = sort_end = 0; |
|
1120 |
||
1121 |
while (i < _fios_num) { |
|
1122 |
if (_fios_list[i].type == FIOS_TYPE_DIR || _fios_list[i].type == FIOS_TYPE_PARENT) |
|
1123 |
sort_start++; |
|
1124 |
||
1125 |
if (_fios_list[i].type == FIOS_TYPE_DRIVE) |
|
1126 |
sort_end++; |
|
1127 |
||
1128 |
i++; |
|
1129 |
} |
|
1130 |
||
1131 |
s_amount = _fios_num - sort_start - sort_end; |
|
1105 | 1132 |
if (s_amount > 0) |
0 | 1133 |
qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems); |
1134 |
} |
|
1135 |
||
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1136 |
static void GenerateFileName(void) |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1137 |
{ |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1138 |
const Player *p; |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1139 |
/* 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
|
1140 |
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
|
1141 |
if (_local_player < MAX_PLAYERS) |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1142 |
p = DEREF_PLAYER(_local_player); |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1143 |
else |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1144 |
p = DEREF_PLAYER(0); |
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1145 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1146 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1147 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1148 |
SetDParam(2, _date); |
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1149 |
GetString(_edit_str_buf, STR_4004); |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1150 |
} |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1151 |
|
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1152 |
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
|
1153 |
|
0 | 1154 |
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) |
1155 |
{ |
|
1156 |
switch(e->event) { |
|
1157 |
case WE_PAINT: { |
|
1158 |
int y,pos; |
|
1159 |
const FiosItem *item; |
|
1160 |
||
1161 |
SetVScrollCount(w, _fios_num); |
|
1162 |
DrawWindowWidgets(w); |
|
1163 |
DrawFiosTexts(); |
|
1164 |
||
1165 |
if (_savegame_sort_dirty) { |
|
1166 |
_savegame_sort_dirty = false; |
|
1167 |
MakeSortedSaveGameList(); |
|
1168 |
} |
|
1169 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1170 |
GfxFillRect(w->widget[6].left + 1, w->widget[6].top + 1, w->widget[6].right, w->widget[6].bottom, 0xD7); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1171 |
DoDrawString(_savegame_sort_order & 1 ? "\xAA" : "\xA0", _savegame_sort_order <= 1 ? w->widget[3].right - 9 : w->widget[2].right - 9, 15, 0x10); |
0 | 1172 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1173 |
y = w->widget[6].top + 1; |
0 | 1174 |
pos = w->vscroll.pos; |
1175 |
while (pos < _fios_num) { |
|
1176 |
item = _fios_list + pos; |
|
1177 |
DoDrawString(item->title[0] ? item->title : item->name, 4, y, _fios_colors[item->type] ); |
|
1178 |
pos++; |
|
1179 |
y+=10; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1180 |
if (y >= w->vscroll.cap*10+w->widget[6].top+1) |
0 | 1181 |
break; |
1182 |
} |
|
1183 |
||
1184 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
|
1185 |
DrawEditBox(w, 9); |
|
1186 |
} |
|
1187 |
break; |
|
1188 |
} |
|
1189 |
case WE_CLICK: |
|
1190 |
switch(e->click.widget) { |
|
1191 |
case 2: /* Sort save names by name */ |
|
1192 |
_savegame_sort_order = (_savegame_sort_order == 2) ? 3 : 2; |
|
1193 |
_savegame_sort_dirty = true; |
|
1194 |
SetWindowDirty(w); |
|
1195 |
break; |
|
1196 |
||
1197 |
case 3: /* Sort save names by date */ |
|
1198 |
_savegame_sort_order = (_savegame_sort_order == 0) ? 1 : 0; |
|
1199 |
_savegame_sort_dirty = true; |
|
1200 |
SetWindowDirty(w); |
|
1201 |
break; |
|
1202 |
||
1203 |
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
|
1204 |
int y = (e->click.pt.y - w->widget[6].top - 1) / 10; |
0 | 1205 |
char *name; |
1206 |
const FiosItem *file; |
|
1207 |
||
1208 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) |
|
1209 |
return; |
|
1210 |
||
1211 |
file = _fios_list + y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1212 |
|
0 | 1213 |
if ((name = FiosBrowseTo(file)) != NULL) { |
1214 |
if (_saveload_mode == SLD_LOAD_GAME) { |
|
1215 |
_switch_mode = SM_LOAD; |
|
1216 |
SetFiosType(file->type); |
|
1217 |
strcpy(_file_to_saveload.name, name); |
|
1218 |
DeleteWindow(w); |
|
1219 |
} else if (_saveload_mode == SLD_LOAD_SCENARIO) { |
|
1220 |
_switch_mode = SM_LOAD_SCENARIO; |
|
1221 |
SetFiosType(file->type); |
|
1222 |
strcpy(_file_to_saveload.name, name); |
|
1223 |
DeleteWindow(w); |
|
1224 |
} else { |
|
1225 |
// SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox |
|
1226 |
strcpy(WP(w,querystr_d).buf, file->title[0] ? file->title : file->name); |
|
1227 |
InvalidateWidget(w, 9); |
|
1228 |
} |
|
1229 |
} else { |
|
1230 |
// Changed directory, need repaint. |
|
1231 |
SetWindowDirty(w); |
|
1232 |
BuildFileList(); |
|
1233 |
} |
|
1234 |
break; |
|
1235 |
} |
|
1236 |
case 10: case 11: /* Delete, Save game */ |
|
1237 |
break; |
|
1238 |
} |
|
1239 |
break; |
|
1240 |
case WE_MOUSELOOP: |
|
1241 |
HandleEditBox(w, 9); |
|
1242 |
break; |
|
1243 |
case WE_KEYPRESS: |
|
1244 |
switch (HandleEditBoxKey(w, 9, e)) { |
|
1245 |
case 1: |
|
1246 |
HandleButtonClick(w, 11); |
|
1247 |
break; |
|
1248 |
} |
|
1249 |
break; |
|
1250 |
case WE_TIMEOUT: |
|
1251 |
if (HASBIT(w->click_state, 10)) { /* Delete button clicked */ |
|
1252 |
FiosDelete(WP(w,querystr_d).buf); |
|
1253 |
SetWindowDirty(w); |
|
1254 |
BuildFileList(); |
|
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1255 |
if (_saveload_mode == SLD_SAVE_GAME) |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1256 |
GenerateFileName(); /* Reset file name to current date */ |
0 | 1257 |
} else if (HASBIT(w->click_state, 11)) { /* Save button clicked */ |
1258 |
_switch_mode = SM_SAVE; |
|
1259 |
FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).buf); |
|
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1260 |
|
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1261 |
/* 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
|
1262 |
if (_game_mode == GM_EDITOR) StartupEngines(); |
0 | 1263 |
} |
1264 |
break; |
|
1265 |
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
|
1266 |
// 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
|
1267 |
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
|
1268 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
0 | 1269 |
_query_string_active = false; |
1270 |
FiosFreeSavegameList(); |
|
1271 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1272 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1273 |
/* 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
|
1274 |
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
|
1275 |
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
|
1276 |
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
|
1277 |
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
|
1278 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1279 |
/* Same for widget 10 and 11 in save-dialog */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1280 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1281 |
w->widget[10].right += diff; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1282 |
w->widget[11].left += diff; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1283 |
w->widget[11].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
|
1284 |
} |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1285 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1286 |
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
|
1287 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1288 |
} |
0 | 1289 |
} |
1290 |
||
1291 |
static const WindowDesc _load_dialog_desc = { |
|
1292 |
WDP_CENTER, WDP_CENTER, 257, 294, |
|
1293 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1294 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1295 |
_load_dialog_1_widgets, |
1296 |
SaveLoadDlgWndProc, |
|
1297 |
}; |
|
1298 |
||
1299 |
static const WindowDesc _load_dialog_scen_desc = { |
|
1300 |
WDP_CENTER, WDP_CENTER, 257, 294, |
|
1301 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1302 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1303 |
_load_dialog_2_widgets, |
1304 |
SaveLoadDlgWndProc, |
|
1305 |
}; |
|
1306 |
||
1307 |
static const WindowDesc _save_dialog_desc = { |
|
1308 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1309 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1310 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1311 |
_save_dialog_widgets, |
1312 |
SaveLoadDlgWndProc, |
|
1313 |
}; |
|
1314 |
||
1315 |
static const WindowDesc _save_dialog_scen_desc = { |
|
1316 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1317 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1318 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1319 |
_save_dialog_scen_widgets, |
1320 |
SaveLoadDlgWndProc, |
|
1321 |
}; |
|
1322 |
||
1323 |
static const WindowDesc * const _saveload_dialogs[] = { |
|
1324 |
&_load_dialog_desc, |
|
1325 |
&_load_dialog_scen_desc, |
|
1326 |
&_save_dialog_desc, |
|
1327 |
&_save_dialog_scen_desc, |
|
1328 |
}; |
|
1329 |
||
1330 |
void ShowSaveLoadDialog(int mode) |
|
1331 |
{ |
|
1332 |
Window *w; |
|
1333 |
||
1334 |
SetObjectToPlace(1, 0, 0, 0); |
|
1335 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1336 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1337 |
||
1338 |
_saveload_mode = mode; |
|
1339 |
||
1340 |
w = AllocateWindowDesc(_saveload_dialogs[mode]); |
|
1341 |
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
|
1342 |
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
|
1343 |
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
|
1344 |
w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
0 | 1345 |
w->click_state |= (1 << 6); |
1346 |
WP(w,querystr_d).caret = 0; |
|
1347 |
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN; |
|
1348 |
WP(w,querystr_d).maxwidth = 240; |
|
1349 |
WP(w,querystr_d).buf = _edit_str_buf; |
|
1350 |
||
1351 |
if (mode == SLD_SAVE_GAME) { |
|
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1352 |
GenerateFileName(); |
0 | 1353 |
} else if (mode == SLD_SAVE_SCENARIO) { |
1354 |
strcpy(_edit_str_buf, "UNNAMED"); |
|
1355 |
} |
|
1356 |
||
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
|
1357 |
// 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
|
1358 |
// 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
|
1359 |
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
|
1360 |
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
|
1361 |
|
0 | 1362 |
BuildFileList(); |
1363 |
||
1364 |
ResetObjectToPlace(); |
|
1365 |
} |
|
1366 |
||
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
|
1367 |
void RedrawAutosave(void) |
0 | 1368 |
{ |
1369 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
|
1370 |
} |
|
1371 |
||
1372 |
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
|
1373 |
{ 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
|
1374 |
{ 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
|
1375 |
{ 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
|
1376 |
{ 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
|
1377 |
{ 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
|
1378 |
{ 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
|
1379 |
{ 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
|
1380 |
{ 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
|
1381 |
{ 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
|
1382 |
{ WIDGETS_END}, |
0 | 1383 |
}; |
1384 |
||
1385 |
static void SelectScenarioWndProc(Window *w, WindowEvent *e) { |
|
1386 |
const int list_start = 45; |
|
1387 |
switch(e->event) { |
|
1388 |
case WE_PAINT: |
|
1389 |
{ |
|
1390 |
int y,pos; |
|
1391 |
const FiosItem *item; |
|
1392 |
||
1393 |
if (_savegame_sort_dirty) { |
|
1394 |
_savegame_sort_dirty = false; |
|
1395 |
MakeSortedSaveGameList(); |
|
1396 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1397 |
|
0 | 1398 |
SetVScrollCount(w, _fios_num); |
1399 |
||
1400 |
DrawWindowWidgets(w); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1401 |
DoDrawString(_savegame_sort_order & 1 ? "\xAA" : "\xA0", _savegame_sort_order <= 1 ? w->widget[4].right - 9 : w->widget[3].right - 9, 15, 0x10); |
0 | 1402 |
DrawString(4, 32, STR_4010_GENERATE_RANDOM_NEW_GAME, 9); |
1403 |
||
1404 |
y = list_start; |
|
1405 |
pos = w->vscroll.pos; |
|
1406 |
while (pos < _fios_num) { |
|
1407 |
item = _fios_list + pos; |
|
1408 |
DoDrawString(item->title[0] ? item->title : item->name, 4, y, _fios_colors[item->type] ); |
|
1409 |
pos++; |
|
1410 |
y+=10; |
|
1411 |
if (y >= w->vscroll.cap*10+list_start) |
|
1412 |
break; |
|
1413 |
} |
|
1414 |
} |
|
1415 |
break; |
|
1416 |
||
1417 |
case WE_CLICK: |
|
1418 |
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
|
1419 |
case 3: /* Sort scenario names by name */ |
0 | 1420 |
_savegame_sort_order = (_savegame_sort_order == 2) ? 3 : 2; |
1421 |
_savegame_sort_dirty = true; |
|
1422 |
SetWindowDirty(w); |
|
1423 |
break; |
|
1424 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1425 |
case 4: /* Sort scenario names by date */ |
0 | 1426 |
_savegame_sort_order = (_savegame_sort_order == 0) ? 1 : 0; |
1427 |
_savegame_sort_dirty = true; |
|
1428 |
SetWindowDirty(w); |
|
1429 |
break; |
|
1430 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1431 |
case 6: /* Click the listbox */ |
0 | 1432 |
if(e->click.pt.y < list_start) |
1433 |
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME); |
|
1434 |
else { |
|
1435 |
char *name; |
|
1436 |
int y = (e->click.pt.y - list_start) / 10; |
|
1437 |
const FiosItem *file; |
|
1438 |
||
1439 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) |
|
1440 |
return; |
|
1441 |
||
1442 |
file = _fios_list + y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1443 |
|
0 | 1444 |
if ((name = FiosBrowseTo(file)) != NULL) { |
1445 |
SetFiosType(file->type); |
|
1446 |
strcpy(_file_to_saveload.name, name); |
|
1447 |
DeleteWindow(w); |
|
1448 |
DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_START_SCENARIO); |
|
1449 |
} |
|
1450 |
} |
|
1451 |
break; |
|
1452 |
} |
|
1453 |
case WE_DESTROY: |
|
1454 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1455 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1456 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1457 |
/* 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
|
1458 |
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
|
1459 |
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
|
1460 |
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
|
1461 |
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
|
1462 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1463 |
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
|
1464 |
} break; |
0 | 1465 |
} |
1466 |
} |
|
1467 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1468 |
void SetFiosType(const byte fiostype) |
0 | 1469 |
{ |
1470 |
switch (fiostype) { |
|
1471 |
case FIOS_TYPE_FILE: case FIOS_TYPE_SCENARIO: |
|
1472 |
_file_to_saveload.mode = SL_LOAD; |
|
1473 |
break; |
|
1474 |
case FIOS_TYPE_OLDFILE: case FIOS_TYPE_OLD_SCENARIO: |
|
1475 |
_file_to_saveload.mode = SL_OLD_LOAD; |
|
1476 |
break; |
|
1477 |
default: |
|
1478 |
_file_to_saveload.mode = SL_INVALID; |
|
1479 |
} |
|
1480 |
} |
|
1481 |
||
1482 |
static const WindowDesc _select_scenario_desc = { |
|
1483 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
1484 |
WC_SAVELOAD,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1485 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1486 |
_select_scenario_widgets, |
1487 |
SelectScenarioWndProc |
|
1488 |
}; |
|
1489 |
||
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
|
1490 |
void AskForNewGameToStart(void) |
0 | 1491 |
{ |
1492 |
Window *w; |
|
1493 |
||
1494 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1495 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1496 |
||
1497 |
_saveload_mode = SLD_NEW_GAME; |
|
1498 |
BuildFileList(); |
|
1499 |
||
1500 |
w = AllocateWindowDesc(&_select_scenario_desc); |
|
1501 |
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
|
1502 |
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
|
1503 |
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
|
1504 |
w->resize.height = w->height - 10 * 17; // Minimum of 10 in the list |
0 | 1505 |
} |
1506 |
||
410 | 1507 |
static int32 ClickMoneyCheat(int32 p1, int32 p2) |
0 | 1508 |
{ |
1509 |
DoCommandP(0, -10000000, 0, NULL, CMD_MONEY_CHEAT); |
|
1510 |
return true; |
|
1511 |
} |
|
1512 |
||
1513 |
// p1 player to set to, p2 is -1 or +1 (down/up) |
|
410 | 1514 |
static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
0 | 1515 |
{ |
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1516 |
while(p1 >= 0 && p1 < MAX_PLAYERS) { |
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1517 |
if (_players[p1].is_active) { |
0 | 1518 |
_local_player = p1; |
138
6ab4d97d1034
(svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents:
108
diff
changeset
|
1519 |
MarkWholeScreenDirty(); |
0 | 1520 |
return _local_player; |
1521 |
} |
|
1522 |
p1 += p2; |
|
1523 |
} |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1524 |
|
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1525 |
return _local_player; |
0 | 1526 |
} |
1527 |
||
100 | 1528 |
// p1 -1 or +1 (down/up) |
1095 | 1529 |
static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
100 | 1530 |
{ |
104 | 1531 |
if(p1==-1) p1 = 3; |
1532 |
if(p1==4) p1 = 0; |
|
100 | 1533 |
_opt.landscape = p1; |
1534 |
GfxLoadSprites(); |
|
1535 |
MarkWholeScreenDirty(); |
|
1536 |
return _opt.landscape; |
|
1537 |
} |
|
1538 |
||
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
|
1539 |
extern void EnginesMonthlyLoop(void); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1540 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1541 |
// p2 1 (increase) or -1 (decrease) |
1095 | 1542 |
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
|
1543 |
{ |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1544 |
YearMonthDay ymd; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1545 |
ConvertDayToYMD(&ymd, _date); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1546 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1547 |
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
|
1548 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1549 |
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
|
1550 |
EnginesMonthlyLoop(); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1551 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1552 |
return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1553 |
} |
100 | 1554 |
|
0 | 1555 |
typedef int32 CheckButtonClick(int32, int32); |
1556 |
||
1557 |
typedef struct CheatEntry { |
|
1558 |
byte type; // type of selector |
|
1559 |
byte flags; // selector flags |
|
1560 |
StringID str; // string with descriptive text |
|
1561 |
void *variable; // pointer to the variable |
|
1562 |
bool *been_used; // has this cheat been used before? |
|
1563 |
CheckButtonClick *click_proc; // procedure |
|
1564 |
int16 min,max; // range for spinbox setting |
|
1565 |
uint16 step; // step for spinbox |
|
1566 |
} CheatEntry; |
|
1567 |
||
1568 |
enum { |
|
1569 |
CE_BOOL = 0, |
|
1570 |
CE_UINT8 = 1, |
|
1571 |
CE_INT16 = 2, |
|
1572 |
CE_UINT16 = 3, |
|
1573 |
CE_INT32 = 4, |
|
1574 |
CE_BYTE = 5, |
|
1575 |
CE_CLICK = 6, |
|
1576 |
||
1577 |
CF_0ISDIS = 1, |
|
1578 |
CF_NOCOMMA = 2, |
|
1579 |
}; |
|
1580 |
||
1581 |
static int32 ReadCE(const CheatEntry*ce) |
|
1582 |
{ |
|
1583 |
switch(ce->type) { |
|
1584 |
case CE_BOOL: return *(bool*)ce->variable; |
|
1585 |
case CE_UINT8: return *(uint8*)ce->variable; |
|
1586 |
case CE_INT16: return *(int16*)ce->variable; |
|
1587 |
case CE_UINT16: return *(uint16*)ce->variable; |
|
1588 |
case CE_INT32: return *(int32*)ce->variable; |
|
1589 |
case CE_BYTE: return *(byte*)ce->variable; |
|
1590 |
case CE_CLICK: return 0; |
|
1591 |
default: |
|
1592 |
NOT_REACHED(); |
|
1593 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1594 |
|
0 | 1595 |
/* useless, but avoids compiler warning this way */ |
1596 |
return 0; |
|
1597 |
} |
|
1598 |
||
1599 |
static void WriteCE(const CheatEntry *ce, int32 val) |
|
1600 |
{ |
|
1601 |
switch(ce->type) { |
|
1602 |
case CE_BOOL: *(bool*)ce->variable = (bool)val; break; |
|
1603 |
case CE_BYTE: *(byte*)ce->variable = (byte)val; break; |
|
1604 |
case CE_UINT8: *(uint8*)ce->variable = (uint8)val; break; |
|
1605 |
case CE_INT16: *(int16*)ce->variable = (int16)val; break; |
|
1606 |
case CE_UINT16: *(uint16*)ce->variable = (uint16)val; break; |
|
1607 |
case CE_INT32: *(int32*)ce->variable = val; break; |
|
1608 |
case CE_CLICK: break; |
|
1609 |
default: |
|
1610 |
NOT_REACHED(); |
|
1611 |
} |
|
1612 |
} |
|
1613 |
||
1614 |
||
1615 |
static const CheatEntry _cheats_ui[] = { |
|
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
176
diff
changeset
|
1616 |
{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
|
1617 |
{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
|
1618 |
{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
|
1619 |
{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
|
1620 |
{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
|
1621 |
{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
|
1622 |
{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
|
1623 |
{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
|
1624 |
{CE_UINT8, 0, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1, 1}, |
0 | 1625 |
}; |
1626 |
||
1627 |
||
1628 |
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
|
1629 |
{ 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
|
1630 |
{ 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
|
1631 |
{ 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
|
1632 |
{ 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
|
1633 |
{ WIDGETS_END}, |
0 | 1634 |
}; |
1635 |
||
1636 |
extern void DrawPlayerIcon(int p, int x, int y); |
|
1637 |
||
1638 |
static void CheatsWndProc(Window *w, WindowEvent *e) |
|
1639 |
{ |
|
1640 |
switch(e->event) { |
|
1641 |
case WE_PAINT: { |
|
1642 |
int clk = WP(w,def_d).data_1; |
|
1643 |
const CheatEntry *ce = &_cheats_ui[0]; |
|
1644 |
int32 val; |
|
1645 |
int x, y; |
|
1646 |
int i; |
|
1647 |
||
1648 |
DrawWindowWidgets(w); |
|
1649 |
||
1650 |
DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, 350); |
|
1651 |
||
1652 |
x=0; |
|
1653 |
y=45; |
|
1654 |
||
1655 |
for(i=0; i!=lengthof(_cheats_ui); i++,ce++) { |
|
1656 |
||
1657 |
DrawSprite((SPR_OPENTTD_BASE + ((*ce->been_used)?67:66)), x+5, y+2); |
|
1658 |
||
1659 |
if (ce->type == CE_BOOL) { |
|
1660 |
DrawFrameRect(x+20, y+1, x+30+9, y+9, (*(bool*)ce->variable)?6:4, (*(bool*)ce->variable)?0x20:0); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1661 |
SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
0 | 1662 |
|
1663 |
} else if (ce->type == CE_CLICK) { |
|
1664 |
DrawFrameRect(x+20, y+1, x+30+9, y+9, 0, (WP(w,def_d).data_1==i*2+1)?0x20:0x00); |
|
1665 |
if(i==0) |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1666 |
SetDParam64(0, (int64) 10000000); |
0 | 1667 |
else |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1668 |
SetDParam(0, false); |
0 | 1669 |
|
1670 |
} else { |
|
1671 |
DrawFrameRect(x+20, y+1, x+20+9, y+9, 3, clk == i*2+1 ? 0x20 : 0); |
|
1672 |
DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? 0x20 : 0); |
|
1673 |
DrawStringCentered(x+25, y+1, STR_6819, 0); |
|
1674 |
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
|
1675 |
|
0 | 1676 |
val = ReadCE(ce); |
100 | 1677 |
|
1678 |
// set correct string for switch climate cheat |
|
1679 |
if(ce->str==STR_CHEAT_SWITCH_CLIMATE) |
|
1680 |
val += STR_TEMPERATE_LANDSCAPE; |
|
1681 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1682 |
SetDParam(0, val); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1683 |
|
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1684 |
// display date for change date cheat |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1685 |
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
|
1686 |
SetDParam(0, _date); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1687 |
|
0 | 1688 |
// draw colored flag for change player cheat |
1689 |
if(ce->str==STR_CHEAT_CHANGE_PLAYER) |
|
1690 |
DrawPlayerIcon(_current_player, 156, y+2); |
|
1691 |
||
1692 |
} |
|
1693 |
||
1694 |
DrawString(50, y+1, ce->str, 0); |
|
1695 |
||
1696 |
y+=12; |
|
1697 |
} |
|
1698 |
break; |
|
1699 |
} |
|
1700 |
case WE_CLICK: { |
|
1701 |
const CheatEntry *ce; |
|
1702 |
uint btn = (e->click.pt.y - 46) / 12; |
|
1703 |
int32 val, oval; |
|
1704 |
uint x = e->click.pt.x; |
|
1705 |
||
1706 |
// not clicking a button? |
|
1707 |
if(!IS_INT_INSIDE(x, 20, 40) || btn>=lengthof(_cheats_ui)) |
|
1708 |
break; |
|
1709 |
||
1710 |
ce = &_cheats_ui[btn]; |
|
1711 |
oval = val = ReadCE(ce); |
|
1712 |
||
1713 |
*ce->been_used = true; |
|
1714 |
||
1715 |
switch(ce->type) { |
|
1716 |
case CE_BOOL: { |
|
1717 |
val ^= 1; |
|
1718 |
if (ce->click_proc != NULL) |
|
1719 |
ce->click_proc(val, 0); |
|
1720 |
break; |
|
1721 |
} |
|
1722 |
||
1723 |
case CE_CLICK: { |
|
1724 |
ce->click_proc(val, 0); |
|
1725 |
WP(w,def_d).data_1 = btn * 2 + 1; |
|
1726 |
break; |
|
1727 |
} |
|
1728 |
||
1729 |
default: { |
|
1730 |
if (x >= 30) { |
|
1731 |
//increase |
|
1732 |
val += ce->step; |
|
1733 |
if (val > ce->max) val = ce->max; |
|
1734 |
} else { |
|
1735 |
// decrease |
|
1736 |
val -= ce->step; |
|
1737 |
if (val < ce->min) val = ce->min; |
|
1738 |
} |
|
1739 |
||
1740 |
// take whatever the function returns |
|
1741 |
val = ce->click_proc(val, (x>=30) ? 1 : -1); |
|
1742 |
||
1743 |
if (val != oval) |
|
1744 |
WP(w,def_d).data_1 = btn * 2 + 1 + ((x>=30) ? 1 : 0); |
|
1745 |
||
1746 |
break; |
|
1747 |
} |
|
1748 |
} |
|
1749 |
||
1750 |
if (val != oval) { |
|
1751 |
WriteCE(ce, val); |
|
1752 |
SetWindowDirty(w); |
|
1753 |
} |
|
1754 |
||
1755 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
1756 |
||
1757 |
SetWindowDirty(w); |
|
1758 |
} |
|
1759 |
break; |
|
1760 |
case WE_TIMEOUT: |
|
1761 |
WP(w,def_d).data_1 = 0; |
|
1762 |
SetWindowDirty(w); |
|
1763 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1764 |
} |
0 | 1765 |
} |
1766 |
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
|
1767 |
240, 22, 400, 160, |
0 | 1768 |
WC_CHEATS,0, |
1769 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1770 |
_cheat_widgets, |
|
1771 |
CheatsWndProc |
|
1772 |
}; |
|
1773 |
||
1774 |
||
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
|
1775 |
void ShowCheatWindow(void) |
0 | 1776 |
{ |
1777 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1778 |
|
0 | 1779 |
DeleteWindowById(WC_CHEATS, 0); |
1780 |
w = AllocateWindowDesc(&_cheats_desc); |
|
1781 |
||
1782 |
if (w) |
|
1783 |
SetWindowDirty(w); |
|
1784 |
} |