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