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