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