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