author | rubidium |
Thu, 21 Jun 2007 19:08:47 +0000 | |
changeset 7502 | 71f5d2c6a605 |
parent 7498 | ce6588257e8d |
child 7503 | 019993e97f08 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
3 |
/** @file misc_gui.cpp */ |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1879
diff
changeset
|
6 |
#include "openttd.h" |
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
7 |
#include "hal.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
8 |
#include "heightmap.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1274
diff
changeset
|
9 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2162
diff
changeset
|
10 |
#include "functions.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6676
diff
changeset
|
11 |
#include "landscape.h" |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
12 |
#include "newgrf.h" |
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
2159
diff
changeset
|
13 |
#include "saveload.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
|
14 |
#include "strings.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1349
diff
changeset
|
15 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
485
diff
changeset
|
16 |
#include "table/strings.h" |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1694
diff
changeset
|
17 |
#include "table/tree_land.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
|
18 |
#include "map.h" |
0 | 19 |
#include "window.h" |
20 |
#include "gui.h" |
|
21 |
#include "viewport.h" |
|
22 |
#include "gfx.h" |
|
23 |
#include "station.h" |
|
24 |
#include "command.h" |
|
25 |
#include "player.h" |
|
26 |
#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
|
27 |
#include "sound.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5698
diff
changeset
|
28 |
#include "network/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
|
29 |
#include "string.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2134
diff
changeset
|
30 |
#include "variables.h" |
3890
f8f13a91446a
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents:
3798
diff
changeset
|
31 |
#include "vehicle.h" |
f8f13a91446a
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents:
3798
diff
changeset
|
32 |
#include "train.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
33 |
#include "tgp.h" |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
34 |
#include "settings.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4223
diff
changeset
|
35 |
#include "date.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
36 |
#include "cargotype.h" |
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6417
diff
changeset
|
37 |
#include "player_face.h" |
7371
b86b05214afe
(svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.
rubidium
parents:
7187
diff
changeset
|
38 |
#include "fileio.h" |
1341
3533880da5d5
(svn r1845) - Revert r1835 since it totally screws network compiling
darkvater
parents:
1336
diff
changeset
|
39 |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
40 |
#include "fileio.h" |
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
41 |
#include "fios.h" |
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
42 |
/* Variables to display file lists */ |
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
43 |
FiosItem *_fios_list; |
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
44 |
int _saveload_mode; |
0 | 45 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
46 |
|
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
47 |
static bool _fios_path_changed; |
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
|
48 |
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
|
49 |
|
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
50 |
enum { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
51 |
LAND_INFO_LINES = 7, |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
52 |
LAND_INFO_LINE_BUFF_SIZE = 512, |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
53 |
}; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
54 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
55 |
static char _landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE]; |
0 | 56 |
|
57 |
static void LandInfoWndProc(Window *w, WindowEvent *e) |
|
58 |
{ |
|
59 |
if (e->event == WE_PAINT) { |
|
60 |
DrawWindowWidgets(w); |
|
61 |
||
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
62 |
DoDrawStringCentered(140, 16, _landinfo_data[0], 13); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
63 |
DoDrawStringCentered(140, 27, _landinfo_data[1], 0); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
64 |
DoDrawStringCentered(140, 38, _landinfo_data[2], 0); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
65 |
DoDrawStringCentered(140, 49, _landinfo_data[3], 0); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
66 |
DoDrawStringCentered(140, 60, _landinfo_data[4], 0); |
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
67 |
if (_landinfo_data[5][0] != '\0') DrawStringMultiCenter(140, 76, BindCString(_landinfo_data[5]), w->width - 4); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
68 |
if (_landinfo_data[6][0] != '\0') DoDrawStringCentered(140, 71, _landinfo_data[6], 0); |
0 | 69 |
} |
70 |
} |
|
71 |
||
72 |
static const Widget _land_info_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
73 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
74 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
75 |
{ WWT_PANEL, 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
|
76 |
{ WIDGETS_END}, |
0 | 77 |
}; |
78 |
||
79 |
static const WindowDesc _land_info_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5039
diff
changeset
|
80 |
WDP_AUTO, WDP_AUTO, 280, 93, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
81 |
WC_LAND_INFO, WC_NONE, |
0 | 82 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
83 |
_land_info_widgets, |
|
84 |
LandInfoWndProc |
|
85 |
}; |
|
86 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
87 |
static void Place_LandInfo(TileIndex tile) |
0 | 88 |
{ |
89 |
Player *p; |
|
90 |
Window *w; |
|
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
91 |
Town *t; |
7449
5cedaf2c861c
(svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents:
7448
diff
changeset
|
92 |
Money old_money; |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7442
diff
changeset
|
93 |
CommandCost costclear; |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
94 |
AcceptedCargo ac; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
95 |
TileDesc td; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
96 |
StringID str; |
0 | 97 |
|
98 |
DeleteWindowById(WC_LAND_INFO, 0); |
|
99 |
||
100 |
w = AllocateWindowDesc(&_land_info_desc); |
|
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
101 |
WP(w, void_d).data = &_landinfo_data; |
0 | 102 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
103 |
p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
104 |
t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
3
27d9e9fa999a
(svn r4) -Fix [996025] _local_player fixes. Fixes wrong memory access (TrueLight)
darkvater
parents:
0
diff
changeset
|
105 |
|
7448
424ab8df8adb
(svn r10207) -Codechange: remove the redundant player_money in favour of the money64, which is now renamed to player_money.
rubidium
parents:
7446
diff
changeset
|
106 |
old_money = p->player_money; |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7449
diff
changeset
|
107 |
p->player_money = INT64_MAX; |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
108 |
costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR); |
7448
424ab8df8adb
(svn r10207) -Codechange: remove the redundant player_money in favour of the money64, which is now renamed to player_money.
rubidium
parents:
7446
diff
changeset
|
109 |
p->player_money = old_money; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
110 |
|
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
111 |
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */ |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
112 |
td.build_date = 0; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
113 |
GetAcceptedCargo(tile, ac); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
114 |
GetTileDesc(tile, &td); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
115 |
|
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
116 |
SetDParam(0, td.dparam[0]); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
117 |
GetString(_landinfo_data[0], td.str, lastof(_landinfo_data[0])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
118 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
119 |
SetDParam(0, STR_01A6_N_A); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
120 |
if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
121 |
GetString(_landinfo_data[1], STR_01A7_OWNER, lastof(_landinfo_data[1])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
122 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
123 |
str = STR_01A4_COST_TO_CLEAR_N_A; |
7442
a4f7989f27d4
(svn r10200) -Codechange: add "shortcut" for !CmdFailed (CmdSucceeded).
rubidium
parents:
7425
diff
changeset
|
124 |
if (CmdSucceeded(costclear)) { |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
125 |
SetDParam(0, costclear.GetCost()); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
126 |
str = STR_01A5_COST_TO_CLEAR; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
127 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
128 |
GetString(_landinfo_data[2], str, lastof(_landinfo_data[2])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
129 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
130 |
snprintf(_userstring, lengthof(_userstring), "0x%.4X", tile); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
131 |
SetDParam(0, TileX(tile)); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
132 |
SetDParam(1, TileY(tile)); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
133 |
SetDParam(2, STR_SPEC_USERSTRING); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
134 |
GetString(_landinfo_data[3], STR_LANDINFO_COORDS, lastof(_landinfo_data[3])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
135 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
136 |
SetDParam(0, STR_01A9_NONE); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
137 |
if (t != NULL && IsValidTown(t)) { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
138 |
SetDParam(0, STR_TOWN); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
139 |
SetDParam(1, t->index); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
140 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
141 |
GetString(_landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(_landinfo_data[4])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
142 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
143 |
{ |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
144 |
char *p = GetString(_landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(_landinfo_data[5])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
145 |
bool found = false; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
146 |
|
6676
30aea9ac89bc
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6658
diff
changeset
|
147 |
for (CargoID i = 0; i < NUM_CARGO; ++i) { |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
148 |
if (ac[i] > 0) { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
149 |
/* Add a comma between each item. */ |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
150 |
if (found) { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
151 |
*p++ = ','; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
152 |
*p++ = ' '; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
153 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
154 |
found = true; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
155 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
156 |
/* If the accepted value is less than 8, show it in 1/8:ths */ |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
157 |
if (ac[i] < 8) { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
158 |
SetDParam(0, ac[i]); |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
159 |
SetDParam(1, GetCargo(i)->name); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
160 |
p = GetString(p, STR_01D1_8, lastof(_landinfo_data[5])); |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
161 |
} else { |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
162 |
p = GetString(p, GetCargo(i)->name, lastof(_landinfo_data[5])); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
163 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
164 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
165 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
166 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
167 |
if (!found) _landinfo_data[5][0] = '\0'; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
168 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
169 |
|
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
170 |
if (td.build_date != 0) { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
171 |
SetDParam(0, td.build_date); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
172 |
GetString(_landinfo_data[6], STR_BUILD_DATE, lastof(_landinfo_data[6])); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
173 |
} else { |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
174 |
_landinfo_data[6][0] = '\0'; |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
175 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
176 |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
177 |
#if defined(_DEBUG) |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
178 |
# define LANDINFOD_LEVEL 0 |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
179 |
#else |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
180 |
# define LANDINFOD_LEVEL 1 |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
181 |
#endif |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
182 |
DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
183 |
DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
184 |
DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
185 |
DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
186 |
DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
187 |
DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
188 |
DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5); |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
189 |
DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _m[tile].m6); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6574
diff
changeset
|
190 |
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7); |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
191 |
#undef LANDINFOD_LEVEL |
0 | 192 |
} |
193 |
||
6573 | 194 |
void PlaceLandBlockInfo() |
0 | 195 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
196 |
if (_cursor.sprite == SPR_CURSOR_QUERY) { |
0 | 197 |
ResetObjectToPlace(); |
198 |
} else { |
|
199 |
_place_proc = Place_LandInfo; |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
200 |
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, 1, WC_MAIN_TOOLBAR, 0); |
0 | 201 |
} |
202 |
} |
|
203 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
204 |
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
|
205 |
/************************************************************************* |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
206 |
* 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
|
207 |
"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
|
208 |
"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
|
209 |
"", |
1124 | 210 |
"The OpenTTD team (in alphabetical order):", |
5355
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
211 |
" Jean-Francois Claeys (Belugas) - In training, not yet specialized", |
2310
ce948102d659
(svn r2836) fixed the alphabetical order of the credits list like it says it is in
bjarni
parents:
2275
diff
changeset
|
212 |
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder", |
5355
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
213 |
" Matthijs Kooijman (blathijs) - Pathfinder-guru", |
1125 | 214 |
" Victor Fischer (Celestar) - Programming everywhere you need him to", |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
215 |
" Tamás Faragó (Darkvater) - Lead coder", |
5355
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
216 |
" Loïc Guilloux (glx) - In training, not yet specialized", |
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
217 |
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
6565 | 218 |
" Jonathan Coome (Maedhros) - High priest of the newGRF Temple", |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
219 |
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host", |
2748
b5c4fbeadf6d
(svn r3293) - Miscellaneous: add peter1138 as developer
Darkvater
parents:
2737
diff
changeset
|
220 |
" Peter Nelson (peter1138) - Spiritual descendant from newgrf gods", |
5977
8a8c35b46e8d
(svn r8254) -Merge: Release changes from the 0.5 branch back to trunk. This ensures an updated changelog, readme, et.
Darkvater
parents:
5919
diff
changeset
|
221 |
" Remko Bijker (Rubidium) - THE desync hunter", |
1126 | 222 |
" Christoph Mallon (Tron) - Programmer, code correctness police", |
1124 | 223 |
" Patric Stout (TrueLight) - Coder, network guru, SVN- and website host", |
1125 | 224 |
"", |
225 |
"Retired Developers:", |
|
226 |
" 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
|
227 |
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
1826
d123cb6b11dc
(svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents:
1821
diff
changeset
|
228 |
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)", |
5355
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
229 |
" Owen Rudge (orudge) - Forum- and masterserver host, OS/2 port (0.1 - 0.4.8)", |
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 |
"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
|
232 |
" 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
|
233 |
" Marcin Grzegorczyk - For his documentation of TTD internals", |
1577 | 234 |
" Petr Baudis (pasky) - Many patches, newgrf support", |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
235 |
" Stefan Meißner (sign_de) - For his work on the console", |
1826
d123cb6b11dc
(svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents:
1821
diff
changeset
|
236 |
" Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with (and PBS)", |
1124 | 237 |
" Cian Duffy (MYOB) - BeOS port / manual writing", |
4133
88f290592081
(svn r5489) -Fix: corrected tokai's name and morphos details (tokai)
truelight
parents:
4091
diff
changeset
|
238 |
" Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
5355
cd06af29b842
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
239 |
" Richard Kempton (richK) - additional airports, initial TGP implementation", |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
240 |
"", |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
241 |
" Michael Blunck - Pre-Signals and Semaphores © 2003", |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
242 |
" George - Canal/Lock graphics © 2003-2004", |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7166
diff
changeset
|
243 |
" David Dallaston - Tram tracks", |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
244 |
" 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
|
245 |
" 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
|
246 |
" 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
|
247 |
"", |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
248 |
"", |
1124 | 249 |
"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
|
250 |
" 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
|
251 |
}; |
0 | 252 |
|
253 |
static void AboutWindowProc(Window *w, WindowEvent *e) |
|
254 |
{ |
|
2639 | 255 |
switch (e->event) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
break; |
0 | 260 |
case WE_PAINT: { |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
261 |
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
|
262 |
int y = WP(w, scroller_d).height; |
0 | 263 |
DrawWindowWidgets(w); |
264 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
265 |
/* Show original copyright and revision version */ |
1125 | 266 |
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0); |
267 |
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
|
268 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
269 |
/* Show all scrolling credits */ |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
} |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
274 |
y += 10; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
275 |
} |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
276 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
277 |
/* 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
|
278 |
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
|
279 |
|
2134 | 280 |
DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", 16); |
281 |
DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, 0); |
|
6988
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6987
diff
changeset
|
282 |
} break; |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
SetWindowDirty(w); |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
287 |
} |
0 | 288 |
break; |
289 |
} |
|
290 |
} |
|
291 |
||
292 |
static const Widget _about_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
293 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
294 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
295 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
296 |
{ 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
|
297 |
{ WIDGETS_END}, |
0 | 298 |
}; |
299 |
||
300 |
static const WindowDesc _about_desc = { |
|
1125 | 301 |
WDP_CENTER, WDP_CENTER, 420, 272, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
302 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 303 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
304 |
_about_widgets, |
|
305 |
AboutWindowProc |
|
306 |
}; |
|
307 |
||
308 |
||
6573 | 309 |
void ShowAboutWindow() |
0 | 310 |
{ |
311 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
312 |
AllocateWindowDesc(&_about_desc); |
|
313 |
} |
|
314 |
||
315 |
static int _tree_to_plant; |
|
316 |
||
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
317 |
static const PalSpriteID _tree_sprites[] = { |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
318 |
{ 0x655, PAL_NONE }, { 0x663, PAL_NONE }, { 0x678, PAL_NONE }, { 0x62B, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
319 |
{ 0x647, PAL_NONE }, { 0x639, PAL_NONE }, { 0x64E, PAL_NONE }, { 0x632, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
320 |
{ 0x67F, PAL_NONE }, { 0x68D, PAL_NONE }, { 0x69B, PAL_NONE }, { 0x6A9, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
321 |
{ 0x6AF, PAL_NONE }, { 0x6D2, PAL_NONE }, { 0x6D9, PAL_NONE }, { 0x6C4, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
322 |
{ 0x6CB, PAL_NONE }, { 0x6B6, PAL_NONE }, { 0x6BD, PAL_NONE }, { 0x6E0, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
323 |
{ 0x72E, PAL_NONE }, { 0x734, PAL_NONE }, { 0x74A, PAL_NONE }, { 0x74F, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
324 |
{ 0x76B, PAL_NONE }, { 0x78F, PAL_NONE }, { 0x788, PAL_NONE }, { 0x77B, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
325 |
{ 0x75F, PAL_NONE }, { 0x774, PAL_NONE }, { 0x720, PAL_NONE }, { 0x797, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
326 |
{ 0x79E, PAL_NONE }, { 0x7A5, PALETTE_TO_GREEN }, { 0x7AC, PALETTE_TO_RED }, { 0x7B3, PAL_NONE }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
327 |
{ 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED } |
0 | 328 |
}; |
329 |
||
330 |
static void BuildTreesWndProc(Window *w, WindowEvent *e) |
|
331 |
{ |
|
2639 | 332 |
switch (e->event) { |
0 | 333 |
case WE_PAINT: { |
334 |
int x,y; |
|
335 |
int i, count; |
|
336 |
||
337 |
DrawWindowWidgets(w); |
|
338 |
||
339 |
WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape]; |
|
340 |
WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape]; |
|
341 |
||
342 |
x = 18; |
|
343 |
y = 54; |
|
344 |
do { |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
345 |
DrawSprite(_tree_sprites[i].sprite, _tree_sprites[i].pal, x, y); |
0 | 346 |
x += 35; |
347 |
if (!(++i & 3)) { |
|
2639 | 348 |
x -= 35 * 4; |
0 | 349 |
y += 47; |
350 |
} |
|
351 |
} while (--count); |
|
352 |
} break; |
|
353 |
||
354 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
355 |
int wid = e->we.click.widget; |
0 | 356 |
|
2639 | 357 |
switch (wid) { |
0 | 358 |
case 0: |
359 |
ResetObjectToPlace(); |
|
2639 | 360 |
break; |
361 |
||
0 | 362 |
case 3: case 4: case 5: case 6: |
363 |
case 7: case 8: case 9: case 10: |
|
364 |
case 11:case 12: case 13: case 14: |
|
2639 | 365 |
if (wid - 3 >= WP(w,tree_d).count) break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
366 |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
367 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL)) |
0 | 368 |
_tree_to_plant = WP(w,tree_d).base + wid - 3; |
369 |
break; |
|
370 |
||
371 |
case 15: // tree of random type. |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
372 |
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, 1, NULL)) |
0 | 373 |
_tree_to_plant = -1; |
374 |
break; |
|
375 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
376 |
case 16: // place trees randomly over the landscape |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4672
diff
changeset
|
377 |
LowerWindowWidget(w, 16); |
0 | 378 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
541 | 379 |
SndPlayFx(SND_15_BEEP); |
0 | 380 |
PlaceTreesRandomly(); |
381 |
MarkWholeScreenDirty(); |
|
382 |
break; |
|
383 |
} |
|
384 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
385 |
|
0 | 386 |
case WE_PLACE_OBJ: |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
387 |
VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED, DDSP_PLANT_TREES); |
0 | 388 |
VpSetPlaceSizingLimit(20); |
389 |
break; |
|
390 |
||
391 |
case WE_PLACE_DRAG: |
|
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7122
diff
changeset
|
392 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
0 | 393 |
return; |
394 |
||
395 |
case WE_PLACE_MOUSEUP: |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
396 |
if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_PLANT_TREES) { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
397 |
DoCommandP(e->we.place.tile, _tree_to_plant, e->we.place.starttile, NULL, |
0 | 398 |
CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); |
399 |
} |
|
400 |
break; |
|
401 |
||
402 |
case WE_TIMEOUT: |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4672
diff
changeset
|
403 |
RaiseWindowWidget(w, 16); |
0 | 404 |
break; |
405 |
||
406 |
case WE_ABORT_PLACE_OBJ: |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4672
diff
changeset
|
407 |
RaiseWindowButtons(w); |
0 | 408 |
break; |
409 |
} |
|
410 |
} |
|
411 |
||
412 |
static const Widget _build_trees_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
413 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
414 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
415 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 170, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
416 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
417 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
418 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
419 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
420 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
421 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
422 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
423 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
424 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
425 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
426 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
427 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
428 |
{ WWT_TEXTBTN, 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
|
429 |
{ WIDGETS_END}, |
0 | 430 |
}; |
431 |
||
432 |
static const WindowDesc _build_trees_desc = { |
|
433 |
497, 22, 143, 171, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
598
diff
changeset
|
434 |
WC_BUILD_TREES, WC_SCEN_LAND_GEN, |
0 | 435 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
436 |
_build_trees_widgets, |
|
437 |
BuildTreesWndProc |
|
438 |
}; |
|
439 |
||
440 |
static const Widget _build_trees_scen_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
441 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
442 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
443 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 183, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
444 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
445 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
446 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
447 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
448 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
449 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
450 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
451 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
452 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
453 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
454 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
455 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
456 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 140, 157, 168, STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
457 |
{ WWT_TEXTBTN, 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
|
458 |
{ WIDGETS_END}, |
0 | 459 |
}; |
460 |
||
461 |
static const WindowDesc _build_trees_scen_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5039
diff
changeset
|
462 |
WDP_AUTO, WDP_AUTO, 143, 184, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
463 |
WC_BUILD_TREES, WC_NONE, |
0 | 464 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
465 |
_build_trees_scen_widgets, |
|
466 |
BuildTreesWndProc |
|
467 |
}; |
|
468 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
469 |
|
6573 | 470 |
void ShowBuildTreesToolbar() |
0 | 471 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
472 |
if (!IsValidPlayer(_current_player)) return; |
1846
c4c9ded67c3c
(svn r2351) -Fix: It was possible to open more than one tree window
tron
parents:
1843
diff
changeset
|
473 |
AllocateWindowDescFront(&_build_trees_desc, 0); |
0 | 474 |
} |
475 |
||
6573 | 476 |
void ShowBuildTreesScenToolbar() |
0 | 477 |
{ |
478 |
AllocateWindowDescFront(&_build_trees_scen_desc, 0); |
|
479 |
} |
|
480 |
||
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
481 |
static uint64 _errmsg_decode_params[20]; |
0 | 482 |
static StringID _errmsg_message_1, _errmsg_message_2; |
483 |
static uint _errmsg_duration; |
|
484 |
||
485 |
||
486 |
static const Widget _errmsg_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
487 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
488 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
489 |
{ 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
|
490 |
{ WIDGETS_END}, |
0 | 491 |
}; |
492 |
||
493 |
static const Widget _errmsg_face_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
494 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
495 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
496 |
{ 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
|
497 |
{ WIDGETS_END}, |
0 | 498 |
}; |
499 |
||
500 |
static void ErrmsgWndProc(Window *w, WindowEvent *e) |
|
501 |
{ |
|
2639 | 502 |
switch (e->event) { |
0 | 503 |
case WE_PAINT: |
504 |
COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
|
505 |
DrawWindowWidgets(w); |
|
506 |
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
|
507 |
if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { |
0 | 508 |
DrawStringMultiCenter( |
509 |
120, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
510 |
(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15), |
0 | 511 |
_errmsg_message_2, |
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
512 |
w->width - 2); |
0 | 513 |
if (_errmsg_message_1 != INVALID_STRING_ID) |
514 |
DrawStringMultiCenter( |
|
515 |
120, |
|
516 |
30, |
|
517 |
_errmsg_message_1, |
|
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
518 |
w->width - 2); |
0 | 519 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
520 |
const Player *p = GetPlayer((PlayerID)GetDParamX(_errmsg_decode_params,2)); |
0 | 521 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
522 |
||
523 |
DrawStringMultiCenter( |
|
524 |
214, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
525 |
(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45), |
0 | 526 |
_errmsg_message_2, |
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
527 |
w->width - 2); |
0 | 528 |
if (_errmsg_message_1 != INVALID_STRING_ID) |
529 |
DrawStringMultiCenter( |
|
530 |
214, |
|
531 |
90, |
|
532 |
_errmsg_message_1, |
|
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
533 |
w->width - 2); |
0 | 534 |
} |
535 |
break; |
|
536 |
||
537 |
case WE_MOUSELOOP: |
|
2639 | 538 |
if (_right_button_down) DeleteWindow(w); |
0 | 539 |
break; |
2639 | 540 |
|
0 | 541 |
case WE_4: |
2639 | 542 |
if (--_errmsg_duration == 0) DeleteWindow(w); |
0 | 543 |
break; |
2639 | 544 |
|
545 |
case WE_DESTROY: |
|
1860
cc0019652d0e
(svn r2366) Use SetRedErrorSquare() instead of home brewed version
tron
parents:
1846
diff
changeset
|
546 |
SetRedErrorSquare(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
|
547 |
_switch_mode_errorstr = INVALID_STRING_ID; |
0 | 548 |
break; |
549 |
||
550 |
case WE_KEYPRESS: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
551 |
if (e->we.keypress.keycode == WKC_SPACE) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
552 |
/* Don't continue. */ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
553 |
e->we.keypress.cont = false; |
0 | 554 |
DeleteWindow(w); |
555 |
} |
|
556 |
break; |
|
557 |
} |
|
558 |
} |
|
559 |
||
560 |
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) |
|
561 |
{ |
|
562 |
Window *w; |
|
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
563 |
const ViewPort *vp; |
0 | 564 |
Point pt; |
565 |
||
566 |
DeleteWindowById(WC_ERRMSG, 0); |
|
567 |
||
568 |
//assert(msg_2); |
|
569 |
if (msg_2 == 0) msg_2 = STR_EMPTY; |
|
570 |
||
571 |
_errmsg_message_1 = msg_1; |
|
572 |
_errmsg_message_2 = msg_2; |
|
573 |
COPY_OUT_DPARAM(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); |
|
574 |
_errmsg_duration = _patches.errmsg_duration; |
|
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
575 |
if (!_errmsg_duration) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
576 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
577 |
if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) { |
0 | 578 |
|
579 |
if ( (x|y) != 0) { |
|
580 |
pt = RemapCoords2(x, y); |
|
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
581 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
0 | 582 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
583 |
/* move x pos to opposite corner */ |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6988
diff
changeset
|
584 |
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left; |
0 | 585 |
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
|
586 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
587 |
/* move y pos to opposite corner */ |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6988
diff
changeset
|
588 |
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; |
0 | 589 |
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
|
590 |
|
0 | 591 |
} else { |
592 |
pt.x = (_screen.width - 240) >> 1; |
|
593 |
pt.y = (_screen.height - 46) >> 1; |
|
594 |
} |
|
595 |
w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
|
596 |
} else { |
|
597 |
if ( (x|y) != 0) { |
|
598 |
pt = RemapCoords2(x, y); |
|
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
599 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6988
diff
changeset
|
600 |
pt.x = clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6988
diff
changeset
|
601 |
pt.y = clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
0 | 602 |
} else { |
603 |
pt.x = (_screen.width - 334) >> 1; |
|
604 |
pt.y = (_screen.height - 137) >> 1; |
|
605 |
} |
|
606 |
w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
|
607 |
} |
|
608 |
||
609 |
w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
|
610 |
} |
|
611 |
||
612 |
||
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7449
diff
changeset
|
613 |
void ShowEstimatedCostOrIncome(Money cost, int x, int y) |
0 | 614 |
{ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
615 |
StringID msg = STR_0805_ESTIMATED_COST; |
0 | 616 |
|
617 |
if (cost < 0) { |
|
618 |
cost = -cost; |
|
619 |
msg = STR_0807_ESTIMATED_INCOME; |
|
620 |
} |
|
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
621 |
SetDParam(0, cost); |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
622 |
ShowErrorMessage(INVALID_STRING_ID, msg, x, y); |
0 | 623 |
} |
624 |
||
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7449
diff
changeset
|
625 |
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost) |
0 | 626 |
{ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
627 |
StringID msg; |
0 | 628 |
Point pt = RemapCoords(x,y,z); |
629 |
||
630 |
msg = STR_0801_COST; |
|
631 |
if (cost < 0) { |
|
632 |
cost = -cost; |
|
633 |
msg = STR_0803_INCOME; |
|
634 |
} |
|
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
635 |
SetDParam(0, cost); |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
636 |
AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING); |
0 | 637 |
} |
638 |
||
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7449
diff
changeset
|
639 |
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost) |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
640 |
{ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
641 |
Point pt = RemapCoords(x,y,z); |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
642 |
|
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
643 |
SetDParam(0, cost); |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
644 |
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
645 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
646 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
647 |
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent) |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
648 |
{ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
649 |
Point pt = RemapCoords(x, y, z); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
650 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
651 |
SetDParam(0, percent); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
652 |
return AddTextEffect(STR_PERCENT_FULL, pt.x, pt.y, 0xFFFF, TE_STATIC); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
653 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
654 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
655 |
void UpdateFillingPercent(TextEffectID te_id, uint8 percent) |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
656 |
{ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
657 |
SetDParam(0, percent); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
658 |
UpdateTextEffect(te_id, STR_PERCENT_FULL); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
659 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
660 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
661 |
void HideFillingPercent(TextEffectID te_id) |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
662 |
{ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7487
diff
changeset
|
663 |
if (te_id != INVALID_TE_ID) RemoveTextEffect(te_id); |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
664 |
} |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
665 |
|
2275
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
666 |
static const Widget _tooltips_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
667 |
{ 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
|
668 |
{ WIDGETS_END}, |
0 | 669 |
}; |
670 |
||
671 |
||
672 |
static void TooltipsWndProc(Window *w, WindowEvent *e) |
|
673 |
{ |
|
2639 | 674 |
switch (e->event) { |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
675 |
case WE_PAINT: { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
676 |
uint arg; |
2639 | 677 |
GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
678 |
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
679 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
680 |
for (arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
681 |
SetDParam(arg, WP(w, tooltips_d).params[arg]); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
682 |
} |
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
683 |
DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w, tooltips_d).string_id, w->width - 2); |
2639 | 684 |
break; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
685 |
} |
0 | 686 |
|
2639 | 687 |
case WE_MOUSELOOP: |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
688 |
/* We can show tooltips while dragging tools. These are shown as long as |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
689 |
* we are dragging the tool. Normal tooltips work with rmb */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
690 |
if (WP(w, tooltips_d).paramcount == 0 ) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
691 |
if (!_right_button_down) DeleteWindow(w); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
692 |
} else { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
693 |
if (!_left_button_down) DeleteWindow(w); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
694 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
695 |
|
2639 | 696 |
break; |
0 | 697 |
} |
698 |
} |
|
699 |
||
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
700 |
/** Shows a tooltip |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
701 |
* @param str String to be displayed |
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
702 |
* @param paramcount number of params to deal with |
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
703 |
* @param params (optional) up to 5 pieces of additional information that may be |
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
704 |
* added to a tooltip; currently only supports parameters of {NUM} (integer) */ |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7498
diff
changeset
|
705 |
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]) |
0 | 706 |
{ |
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
707 |
char buffer[512]; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
708 |
BoundingRect br; |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
709 |
Window *w; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
710 |
uint i; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
711 |
int x, y; |
0 | 712 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
713 |
DeleteWindowById(WC_TOOLTIPS, 0); |
0 | 714 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
715 |
/* We only show measurement tooltips with patch setting on */ |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
716 |
if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return; |
0 | 717 |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
718 |
for (i = 0; i != paramcount; i++) SetDParam(i, params[i]); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
719 |
GetString(buffer, str, lastof(buffer)); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
720 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
721 |
br = GetStringBoundingBox(buffer); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
722 |
br.width += 6; br.height += 4; // increase slightly to have some space around the box |
0 | 723 |
|
4558
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
724 |
/* Cut tooltip length to 200 pixels max, wrap to new line if longer */ |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
725 |
if (br.width > 200) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
726 |
br.height += ((br.width - 4) / 176) * 10; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
727 |
br.width = 200; |
0 | 728 |
} |
729 |
||
4558
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
730 |
/* Correctly position the tooltip position, watch out for window and cursor size |
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
731 |
* Clamp value to below main toolbar and above statusbar. If tooltip would |
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
732 |
* go below window, flip it so it is shown above the cursor */ |
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
733 |
y = clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
734 |
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
735 |
x = clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); |
0 | 736 |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
737 |
w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
738 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
739 |
WP(w, tooltips_d).string_id = str; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
740 |
assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0])); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
741 |
memcpy(WP(w, tooltips_d).params, params, sizeof(WP(w, tooltips_d).params[0]) * paramcount); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
742 |
WP(w, tooltips_d).paramcount = paramcount; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
743 |
|
4558
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
744 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
745 |
w->widget[0].right = br.width; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
746 |
w->widget[0].bottom = br.height; |
0 | 747 |
} |
748 |
||
749 |
||
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
750 |
static void DrawStationCoverageText(const AcceptedCargo accepts, |
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
751 |
int str_x, int str_y, uint mask) |
0 | 752 |
{ |
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
753 |
char *b = _userstring; |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
754 |
bool first = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
755 |
|
1553
4976359e2bf9
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
756 |
b = InlineString(b, STR_000D_ACCEPTS); |
0 | 757 |
|
6676
30aea9ac89bc
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6658
diff
changeset
|
758 |
for (CargoID i = 0; i < NUM_CARGO; i++, mask >>= 1) { |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
759 |
if (b >= lastof(_userstring) - 5) break; |
1556
4fd2c95e6bc4
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
760 |
if (accepts[i] >= 8 && mask & 1) { |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
761 |
if (first) { |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
762 |
first = false; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
763 |
} else { |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
764 |
/* Add a comma if this is not the first item */ |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
765 |
*b++ = ','; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
766 |
*b++ = ' '; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
767 |
} |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
768 |
b = InlineString(b, GetCargo(i)->name); |
0 | 769 |
} |
770 |
} |
|
771 |
||
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
772 |
/* If first is still true then no cargo is accepted */ |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
773 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
0 | 774 |
|
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
775 |
*b = '\0'; |
0 | 776 |
DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
777 |
} |
|
778 |
||
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
779 |
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) { |
2873 | 780 |
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
781 |
AcceptedCargo accepts; |
2873 | 782 |
if (tile < MapSize()) { |
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3329
diff
changeset
|
783 |
GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
0 | 784 |
DrawStationCoverageText(accepts, sx, sy, mask); |
785 |
} |
|
786 |
} |
|
787 |
||
4171 | 788 |
void CheckRedrawStationCoverage(const Window *w) |
0 | 789 |
{ |
2549 | 790 |
if (_thd.dirty & 1) { |
791 |
_thd.dirty &= ~1; |
|
0 | 792 |
SetWindowDirty(w); |
793 |
} |
|
794 |
} |
|
795 |
||
796 |
void SetVScrollCount(Window *w, int num) |
|
797 |
{ |
|
798 |
w->vscroll.count = num; |
|
799 |
num -= w->vscroll.cap; |
|
800 |
if (num < 0) num = 0; |
|
801 |
if (num < w->vscroll.pos) w->vscroll.pos = num; |
|
802 |
} |
|
803 |
||
842 | 804 |
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
|
805 |
{ |
842 | 806 |
w->vscroll2.count = num; |
807 |
num -= w->vscroll2.cap; |
|
808 |
if (num < 0) num = 0; |
|
809 |
if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
|
810 |
} |
|
811 |
||
0 | 812 |
void SetHScrollCount(Window *w, int num) |
813 |
{ |
|
814 |
w->hscroll.count = num; |
|
815 |
num -= w->hscroll.cap; |
|
816 |
if (num < 0) num = 0; |
|
817 |
if (num < w->hscroll.pos) w->hscroll.pos = num; |
|
818 |
} |
|
819 |
||
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
820 |
/* Delete a character at the caret position in a text buf. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
821 |
* If backspace is set, delete the character before the caret, |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
822 |
* else delete the character after it. */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
823 |
static void DelChar(Textbuf *tb, bool backspace) |
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
|
824 |
{ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
825 |
WChar c; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
826 |
uint width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
827 |
size_t len; |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
828 |
char *s = tb->buf + tb->caretpos; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
829 |
|
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
830 |
if (backspace) s = Utf8PrevChar(s); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
831 |
|
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
832 |
len = Utf8Decode(&c, s); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
833 |
width = GetCharacterWidth(FS_NORMAL, c); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
834 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
835 |
tb->width -= width; |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
836 |
if (backspace) { |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
837 |
tb->caretpos -= len; |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
838 |
tb->caretxoffs -= width; |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
839 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
840 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
841 |
/* Move the remaining characters over the marker */ |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
842 |
memmove(s, s + len, tb->length - (s - tb->buf) - len + 1); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
843 |
tb->length -= len; |
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
|
844 |
} |
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
|
845 |
|
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
|
846 |
/** |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
847 |
* 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
|
848 |
* The character is delete from the position the caret is at |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
849 |
* @param tb Textbuf type to be changed |
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
850 |
* @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE |
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
|
851 |
* @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
|
852 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
853 |
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
|
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 |
if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
856 |
DelChar(tb, true); |
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
|
857 |
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
|
858 |
} else if (delmode == WKC_DELETE && tb->caretpos < tb->length) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
859 |
DelChar(tb, false); |
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
|
860 |
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
|
861 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
862 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
863 |
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
|
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 |
/** |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
867 |
* Delete every character in the textbuffer |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
868 |
* @param tb Textbuf buffer to be emptied |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
869 |
*/ |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
870 |
void DeleteTextBufferAll(Textbuf *tb) |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
871 |
{ |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
872 |
memset(tb->buf, 0, tb->maxlength); |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
873 |
tb->length = tb->width = 0; |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
874 |
tb->caretpos = tb->caretxoffs = 0; |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
875 |
} |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
876 |
|
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
877 |
/** |
3459
b78229520bcf
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
878 |
* Insert a character to a textbuffer. If maxwidth of the Textbuf is zero, |
b78229520bcf
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
879 |
* we don't care about the visual-length but only about the physical |
3458
d3a6ddfa6784
(svn r4301) - Fix: the maxlength parameter of Textbuf is supposed to be the size of the buffer (so length of string + '\0'), but in the code it was a mix of both. It didn't cause any problems though, only an occasionaly one-less character than allowed. (thanks Tron for noticing)
Darkvater
parents:
3421
diff
changeset
|
880 |
* length of the string |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
881 |
* @param tb Textbuf type to be changed |
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
|
882 |
* @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
|
883 |
* @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
|
884 |
*/ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
885 |
bool InsertTextBufferChar(Textbuf *tb, WChar key) |
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
|
886 |
{ |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3719
diff
changeset
|
887 |
const byte charwidth = GetCharacterWidth(FS_NORMAL, key); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
888 |
size_t len = Utf8CharLen(key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
889 |
if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
890 |
memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
891 |
Utf8Encode(tb->buf + tb->caretpos, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
892 |
tb->length += len; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
893 |
tb->width += charwidth; |
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
|
894 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
895 |
tb->caretpos += len; |
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
|
896 |
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
|
897 |
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
|
898 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
899 |
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
|
900 |
} |
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 |
/** |
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 |
* 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
|
904 |
* This defines where the caret will blink and the next characer interaction will occur |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
905 |
* @param tb Textbuf type where navigation occurs |
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
906 |
* @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME |
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
|
907 |
* @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
|
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 |
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
|
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 |
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
|
912 |
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
|
913 |
if (tb->caretpos != 0) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
914 |
WChar c; |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
915 |
const char *s = Utf8PrevChar(tb->buf + tb->caretpos); |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
916 |
Utf8Decode(&c, s); |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
917 |
tb->caretpos = s - tb->buf; // -= (tb->buf + tb->caretpos - s) |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
918 |
tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
919 |
|
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
|
920 |
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
|
921 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
922 |
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
|
923 |
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
|
924 |
if (tb->caretpos < tb->length) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
925 |
WChar c; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
926 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
927 |
tb->caretpos += Utf8Decode(&c, tb->buf + tb->caretpos); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
928 |
tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
929 |
|
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
|
930 |
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
|
931 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
932 |
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
|
933 |
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
|
934 |
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
|
935 |
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
|
936 |
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
|
937 |
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
|
938 |
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
|
939 |
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
|
940 |
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
|
941 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
942 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
943 |
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
|
944 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
945 |
|
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 |
/** |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
947 |
* Initialize the textbuffer by supplying it the buffer to write into |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
948 |
* and the maximum length of this buffer |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
949 |
* @param tb Textbuf type which is getting initialized |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
950 |
* @param buf the buffer that will be holding the data for input |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
951 |
* @param maxlength maximum length in characters of this buffer |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
952 |
* @param maxwidth maximum length in pixels of this buffer. If reached, buffer |
4958 | 953 |
* cannot grow, even if maxlength would allow because there is space. A length |
954 |
* of zero '0' means the buffer is only restricted by maxlength */ |
|
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
955 |
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth) |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
956 |
{ |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
957 |
tb->buf = (char*)buf; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
958 |
tb->maxlength = maxlength; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
959 |
tb->maxwidth = maxwidth; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
960 |
tb->caret = true; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
961 |
UpdateTextBufferSize(tb); |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
962 |
} |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
963 |
|
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
964 |
/** |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
965 |
* Update Textbuf type with its actual physical character and screenlength |
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
|
966 |
* 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
|
967 |
* Useful when copying in a larger amount of text at once |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
968 |
* @param tb Textbuf type which length is calculated |
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
|
969 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
970 |
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
|
971 |
{ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
972 |
const char *buf = tb->buf; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
973 |
WChar c = Utf8Consume(&buf); |
2630 | 974 |
|
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
|
975 |
tb->width = 0; |
5698
6697ee90a195
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5682
diff
changeset
|
976 |
tb->length = 0; |
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
|
977 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
978 |
for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
979 |
tb->width += GetCharacterWidth(FS_NORMAL, c); |
5698
6697ee90a195
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5682
diff
changeset
|
980 |
tb->length += Utf8CharLen(c); |
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
|
981 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
982 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
983 |
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
|
984 |
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
|
985 |
} |
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
|
986 |
|
4909
ef77bf81545c
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents:
4884
diff
changeset
|
987 |
int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e) |
0 | 988 |
{ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
989 |
e->we.keypress.cont = false; |
0 | 990 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
991 |
switch (e->we.keypress.keycode) { |
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
|
992 |
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
|
993 |
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
|
994 |
case (WKC_CTRL | 'V'): |
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
995 |
if (InsertTextBufferClipboard(&string->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
|
996 |
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
|
997 |
break; |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
998 |
case (WKC_CTRL | 'U'): |
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
999 |
DeleteTextBufferAll(&string->text); |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
1000 |
InvalidateWidget(w, wid); |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
1001 |
break; |
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
|
1002 |
case WKC_BACKSPACE: case WKC_DELETE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1003 |
if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) |
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
|
1004 |
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
|
1005 |
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
|
1006 |
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1007 |
if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) |
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
|
1008 |
InvalidateWidget(w, wid); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
1009 |
break; |
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
|
1010 |
default: |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
1011 |
if (IsValidChar(e->we.keypress.key, string->afilter)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
1012 |
if (InsertTextBufferChar(&string->text, e->we.keypress.key)) { |
0 | 1013 |
InvalidateWidget(w, wid); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
1014 |
} |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
1015 |
} else { // key wasn't caught. Continue only if standard entry specified |
4909
ef77bf81545c
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents:
4884
diff
changeset
|
1016 |
e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
1017 |
} |
0 | 1018 |
} |
1019 |
||
1020 |
return 0; |
|
1021 |
} |
|
1022 |
||
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
|
1023 |
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
|
1024 |
{ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1025 |
/* 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
|
1026 |
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
|
1027 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1028 |
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
|
1029 |
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
|
1030 |
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
|
1031 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1032 |
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
|
1033 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1034 |
|
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
1035 |
void HandleEditBox(Window *w, querystr_d *string, int wid) |
0 | 1036 |
{ |
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
1037 |
if (HandleCaret(&string->text)) InvalidateWidget(w, wid); |
0 | 1038 |
} |
1039 |
||
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
1040 |
void DrawEditBox(Window *w, querystr_d *string, int wid) |
0 | 1041 |
{ |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1042 |
DrawPixelInfo dpi, *old_dpi; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1043 |
int delta; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1044 |
const Widget *wi = &w->widget[wid]; |
2887
d5967e472eee
(svn r3439) - CodeChange: Remove a whole bunch of global variables and put them into the WP() macro. Also combine more than one WP-custom element. For this the maximum size of w->custom (WP) has been increased, and multiple types put inside one with possibly moved to the corresponding gui file if it is only used there.
Darkvater
parents:
2873
diff
changeset
|
1045 |
const Textbuf *tb = &string->text; |
0 | 1046 |
|
5890
45bd89352147
(svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents:
5847
diff
changeset
|
1047 |
GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215); |
45bd89352147
(svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents:
5847
diff
changeset
|
1048 |
|
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1049 |
/* Limit the drawing of the string inside the widget boundaries */ |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1050 |
if (!FillDrawPixelInfo(&dpi, |
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
1051 |
wi->left + 4, |
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
1052 |
wi->top + 1, |
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
1053 |
wi->right - wi->left - 4, |
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
1054 |
wi->bottom - wi->top - 1) |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1055 |
) return; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1056 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1057 |
old_dpi = _cur_dpi; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1058 |
_cur_dpi = &dpi; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1059 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1060 |
/* We will take the current widget length as maximum width, with a small |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1061 |
* space reserved at the end for the caret to show */ |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1062 |
delta = (wi->right - wi->left) - tb->width - 10; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1063 |
if (delta > 0) delta = 0; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1064 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1065 |
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1066 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1067 |
DoDrawString(tb->buf, delta, 0, 8); |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1068 |
if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, 12); |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1069 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1070 |
_cur_dpi = old_dpi; |
0 | 1071 |
} |
1072 |
||
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1073 |
enum QueryStringWidgets { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1074 |
QUERY_STR_WIDGET_TEXT = 3, |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1075 |
QUERY_STR_WIDGET_CANCEL, |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1076 |
QUERY_STR_WIDGET_OK |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1077 |
}; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1078 |
|
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1079 |
|
0 | 1080 |
static void QueryStringWndProc(Window *w, WindowEvent *e) |
1081 |
{ |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1082 |
querystr_d *qs = &WP(w, querystr_d); |
0 | 1083 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1084 |
switch (e->event) { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1085 |
case WE_CREATE: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1086 |
SETBIT(_no_scroll, SCROLL_EDIT); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1087 |
break; |
390
672930cad487
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
1088 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1089 |
case WE_PAINT: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1090 |
SetDParam(0, qs->caption); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1091 |
DrawWindowWidgets(w); |
598
200de7111fa9
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
1092 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1093 |
DrawEditBox(w, qs, QUERY_STR_WIDGET_TEXT); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1094 |
break; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1095 |
|
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1096 |
case WE_CLICK: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1097 |
switch (e->we.click.widget) { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1098 |
case QUERY_STR_WIDGET_OK: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1099 |
press_ok:; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1100 |
if (qs->orig == NULL || strcmp(qs->text.buf, qs->orig) != 0) { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1101 |
Window *parent = w->parent; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1102 |
qs->handled = true; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1103 |
|
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1104 |
/* If the parent is NULL, the editbox is handled by general function |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1105 |
* HandleOnEditText */ |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1106 |
if (parent != NULL) { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1107 |
WindowEvent e; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1108 |
e.event = WE_ON_EDIT_TEXT; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1109 |
e.we.edittext.str = qs->text.buf; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1110 |
parent->wndproc(parent, &e); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1111 |
} else { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1112 |
HandleOnEditText(qs->text.buf); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1113 |
} |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1114 |
} |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1115 |
/* Fallthrough */ |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1116 |
case QUERY_STR_WIDGET_CANCEL: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1117 |
DeleteWindow(w); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1118 |
break; |
0 | 1119 |
} |
1120 |
break; |
|
1121 |
||
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1122 |
case WE_MOUSELOOP: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1123 |
HandleEditBox(w, qs, QUERY_STR_WIDGET_TEXT); |
0 | 1124 |
break; |
1125 |
||
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1126 |
case WE_KEYPRESS: |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1127 |
switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1128 |
case 1: goto press_ok; // Enter pressed, confirms change |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1129 |
case 2: DeleteWindow(w); break; // ESC pressed, closes window, abandons changes |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1130 |
} |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1131 |
break; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1132 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1133 |
case WE_DESTROY: // Call cancellation of query, if we have not handled it before |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1134 |
if (!qs->handled && w->parent != NULL) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1135 |
WindowEvent e; |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1136 |
Window *parent = w->parent; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1137 |
|
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1138 |
qs->handled = true; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1139 |
e.event = WE_ON_EDIT_TEXT_CANCEL; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1140 |
parent->wndproc(parent, &e); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1141 |
} |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1142 |
CLRBIT(_no_scroll, SCROLL_EDIT); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1143 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1144 |
} |
0 | 1145 |
} |
1146 |
||
1147 |
static const Widget _query_string_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1148 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1149 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1150 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1151 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1152 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1153 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 130, 259, 30, 41, STR_012F_OK, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
172
diff
changeset
|
1154 |
{ WIDGETS_END}, |
0 | 1155 |
}; |
1156 |
||
1157 |
static const WindowDesc _query_string_desc = { |
|
1158 |
190, 219, 260, 42, |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1159 |
WC_QUERY_STRING, WC_NONE, |
0 | 1160 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1161 |
_query_string_widgets, |
|
1162 |
QueryStringWndProc |
|
1163 |
}; |
|
1164 |
||
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
|
1165 |
static char _edit_str_buf[64]; |
0 | 1166 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1167 |
/** Show a query popup window with a textbox in it. |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1168 |
* @param str StringID for the text shown in the textbox |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1169 |
* @param caption StringID of text shown in caption of querywindow |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1170 |
* @param maxlen maximum length in characters allowed. If bit 12 is set we |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1171 |
* will not check the resulting string against to original string to return success |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1172 |
* @param maxwidth maximum width in pixels allowed |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1173 |
* @param parent pointer to a Window that will handle the events (ok/cancel) of this |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1174 |
* window. If NULL, results are handled by global function HandleOnEditText |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1175 |
* @param afilter filters out unwanted character input */ |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1176 |
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter) |
0 | 1177 |
{ |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1178 |
static char orig_str_buf[lengthof(_edit_str_buf)]; |
0 | 1179 |
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
|
1180 |
uint realmaxlen = maxlen & ~0x1000; |
0 | 1181 |
|
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
|
1182 |
assert(realmaxlen < lengthof(_edit_str_buf)); |
0 | 1183 |
|
1184 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1185 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1186 |
||
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
|
1187 |
w = AllocateWindowDesc(&_query_string_desc); |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1188 |
w->parent = parent; |
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
|
1189 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1190 |
GetString(_edit_str_buf, str, lastof(_edit_str_buf)); |
4949
fa564e9c2aea
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4948
diff
changeset
|
1191 |
_edit_str_buf[realmaxlen - 1] = '\0'; |
596
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1192 |
|
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1193 |
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
|
1194 |
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
|
1195 |
} else { |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1196 |
strecpy(orig_str_buf, _edit_str_buf, lastof(orig_str_buf)); |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1197 |
WP(w, querystr_d).orig = orig_str_buf; |
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
|
1198 |
} |
0 | 1199 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1200 |
LowerWindowWidget(w, QUERY_STR_WIDGET_TEXT); |
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
|
1201 |
WP(w, querystr_d).caption = caption; |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
1202 |
WP(w, querystr_d).afilter = afilter; |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1203 |
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, realmaxlen, maxwidth); |
0 | 1204 |
} |
1205 |
||
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1206 |
|
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1207 |
enum QueryWidgets { |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1208 |
QUERY_WIDGET_CAPTION = 1, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1209 |
QUERY_WIDGET_NO = 3, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1210 |
QUERY_WIDGET_YES |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1211 |
}; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1212 |
|
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1213 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
1214 |
struct query_d { |
5724
e6633aa2c817
(svn r7757) -Fix (r7621): x64 did not compile because query_d was too big. Reorder the elements
Darkvater
parents:
5720
diff
changeset
|
1215 |
void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1216 |
StringID message; ///< message shown for query window |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7498
diff
changeset
|
1217 |
uint64 params[10]; ///< local copy of _decode_parameters |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1218 |
bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
1219 |
}; |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1220 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1221 |
|
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1222 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1223 |
static void QueryWndProc(Window *w, WindowEvent *e) |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1224 |
{ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1225 |
query_d *q = &WP(w, query_d); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1226 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1227 |
switch (e->event) { |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1228 |
case WE_PAINT: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1229 |
COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1230 |
DrawWindowWidgets(w); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1231 |
COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1232 |
|
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
1233 |
DrawStringMultiCenter(w->width / 2, (w->height / 2) - 10, q->message, w->width - 2); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1234 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1235 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1236 |
case WE_CLICK: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1237 |
switch (e->we.click.widget) { |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1238 |
case QUERY_WIDGET_YES: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1239 |
q->calledback = true; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1240 |
if (q->proc != NULL) q->proc(w->parent, true); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1241 |
/* Fallthrough */ |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1242 |
case QUERY_WIDGET_NO: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1243 |
DeleteWindow(w); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1244 |
break; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1245 |
} |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1246 |
break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1247 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1248 |
case WE_KEYPRESS: // ESC closes the window, Enter confirms the action |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1249 |
switch (e->we.keypress.keycode) { |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1250 |
case WKC_RETURN: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1251 |
case WKC_NUM_ENTER: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1252 |
q->calledback = true; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1253 |
if (q->proc != NULL) q->proc(w->parent, true); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1254 |
/* Fallthrough */ |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1255 |
case WKC_ESC: |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1256 |
e->we.keypress.cont = false; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1257 |
DeleteWindow(w); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1258 |
break; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1259 |
} |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1260 |
break; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1261 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1262 |
case WE_DESTROY: // Call callback function (if any) on window close if not yet called |
5680
b0bae92a1620
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5669
diff
changeset
|
1263 |
if (!q->calledback && q->proc != NULL) { |
b0bae92a1620
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5669
diff
changeset
|
1264 |
q->calledback = true; |
b0bae92a1620
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5669
diff
changeset
|
1265 |
q->proc(w->parent, false); |
b0bae92a1620
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5669
diff
changeset
|
1266 |
} |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1267 |
break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1268 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1269 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1270 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1271 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1272 |
static const Widget _query_widgets[] = { |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1273 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1274 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 209, 0, 13, STR_NULL, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1275 |
{ WWT_PANEL, RESIZE_NONE, 4, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1276 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 20, 90, 62, 73, STR_00C9_NO, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1277 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 120, 190, 62, 73, STR_00C8_YES, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1278 |
{ WIDGETS_END }, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1279 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1280 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1281 |
static const WindowDesc _query_desc = { |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1282 |
WDP_CENTER, WDP_CENTER, 210, 82, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1283 |
WC_CONFIRM_POPUP_QUERY, WC_NONE, |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1284 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1285 |
_query_widgets, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1286 |
QueryWndProc |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1287 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1288 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1289 |
/** Show a modal confirmation window with standard 'yes' and 'no' buttons |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1290 |
* The window is aligned to the centre of its parent. |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1291 |
* NOTE: You cannot use BindCString as parameter for this window! |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1292 |
* @param caption string shown as window caption |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1293 |
* @param message string that will be shown for the window |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1294 |
* @param parent pointer to parent window, if this pointer is NULL the parent becomes |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1295 |
* the main window WC_MAIN_WINDOW |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
1296 |
* @param callback callback function pointer to set in the window descriptor*/ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1297 |
void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1298 |
{ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1299 |
Window *w = AllocateWindowDesc(&_query_desc); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1300 |
if (w == NULL) return; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1301 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1302 |
if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1303 |
w->parent = parent; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1304 |
w->left = parent->left + (parent->width / 2) - (w->width / 2); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1305 |
w->top = parent->top + (parent->height / 2) - (w->height / 2); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1306 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1307 |
/* Create a backup of the variadic arguments to strings because it will be |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1308 |
* overridden pretty often. We will copy these back for drawing */ |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1309 |
COPY_OUT_DPARAM(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1310 |
w->widget[QUERY_WIDGET_CAPTION].data = caption; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1311 |
WP(w, query_d).message = message; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1312 |
WP(w, query_d).proc = callback; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1313 |
WP(w, query_d).calledback = false; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1314 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1315 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1316 |
|
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1317 |
static const Widget _load_dialog_widgets[] = { |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1318 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1319 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1320 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1321 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1322 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1323 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 293, 0x0, STR_NULL}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1324 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1325 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 291, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1326 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 281, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1327 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 282, 293, 0x0, STR_RESIZE_BUTTON}, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1328 |
{ WIDGETS_END}, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1329 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1330 |
|
0 | 1331 |
static const Widget _save_dialog_widgets[] = { |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1332 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1333 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1334 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1335 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1336 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1337 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 291, 0x0, STR_NULL}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1338 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1339 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 290, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1340 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 291, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1341 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 256, 292, 307, 0x0, STR_NULL}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1342 |
{ WWT_PANEL, RESIZE_RTB, 14, 2, 254, 294, 305, 0x0, STR_400B_CURRENTLY_SELECTED_NAME}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1343 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 127, 308, 319, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1344 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 128, 244, 308, 319, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1345 |
{ 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
|
1346 |
{ WIDGETS_END}, |
0 | 1347 |
}; |
1348 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1349 |
/* Colors for fios types */ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1350 |
const byte _fios_colors[] = {13, 9, 9, 6, 5, 6, 5, 6, 6, 8}; |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2255
diff
changeset
|
1351 |
|
6573 | 1352 |
void BuildFileList() |
0 | 1353 |
{ |
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1354 |
_fios_path_changed = true; |
0 | 1355 |
FiosFreeSavegameList(); |
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1356 |
|
2549 | 1357 |
switch (_saveload_mode) { |
1358 |
case SLD_NEW_GAME: |
|
1359 |
case SLD_LOAD_SCENARIO: |
|
1360 |
case SLD_SAVE_SCENARIO: |
|
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1361 |
_fios_list = FiosGetScenarioList(_saveload_mode); break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1362 |
case SLD_LOAD_HEIGHTMAP: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1363 |
_fios_list = FiosGetHeightmapList(_saveload_mode); break; |
2549 | 1364 |
|
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1365 |
default: _fios_list = FiosGetSavegameList(_saveload_mode); break; |
2549 | 1366 |
} |
0 | 1367 |
} |
1368 |
||
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1369 |
static void DrawFiosTexts(uint maxw) |
0 | 1370 |
{ |
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1371 |
static const char *path = NULL; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1372 |
static StringID str = STR_4006_UNABLE_TO_READ_DRIVE; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1373 |
static uint32 tot = 0; |
0 | 1374 |
|
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1375 |
if (_fios_path_changed) { |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1376 |
str = FiosGetDescText(&path, &tot); |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1377 |
_fios_path_changed = false; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1378 |
} |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1379 |
|
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1380 |
if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot); |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1381 |
DrawString(2, 37, str, 0); |
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2100
diff
changeset
|
1382 |
DoDrawStringTruncated(path, 2, 27, 16, maxw); |
0 | 1383 |
} |
1384 |
||
6573 | 1385 |
static void MakeSortedSaveGameList() |
0 | 1386 |
{ |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1387 |
uint sort_start = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1388 |
uint sort_end = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1389 |
uint s_amount; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1390 |
int i; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1391 |
|
4171 | 1392 |
/* Directories are always above the files (FIOS_TYPE_DIR) |
1393 |
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE) |
|
1394 |
* Only sort savegames/scenarios, not directories |
|
0 | 1395 |
*/ |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1396 |
for (i = 0; i < _fios_num; i++) { |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1397 |
switch (_fios_list[i].type) { |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1398 |
case FIOS_TYPE_DIR: sort_start++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1399 |
case FIOS_TYPE_PARENT: sort_start++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1400 |
case FIOS_TYPE_DRIVE: sort_end++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1401 |
} |
0 | 1402 |
} |
1403 |
||
1404 |
s_amount = _fios_num - sort_start - sort_end; |
|
1105 | 1405 |
if (s_amount > 0) |
0 | 1406 |
qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems); |
1407 |
} |
|
1408 |
||
6573 | 1409 |
static void GenerateFileName() |
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1410 |
{ |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1411 |
/* 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
|
1412 |
Let's use the name of player #0 for now. */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1413 |
const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
635
5a595bc1653f
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1414 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1415 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1416 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1417 |
SetDParam(2, _date); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1418 |
GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf)); |
7371
b86b05214afe
(svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.
rubidium
parents:
7187
diff
changeset
|
1419 |
SanitizeFilename(_edit_str_buf); |
402
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1420 |
} |
a7dffcd6a4dd
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1421 |
|
6573 | 1422 |
extern void StartupEngines(); |
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1423 |
|
0 | 1424 |
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) |
1425 |
{ |
|
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1426 |
static FiosItem o_dir; |
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1427 |
|
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1428 |
switch (e->event) { |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
1429 |
case WE_CREATE: // Set up OPENTTD button |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1430 |
o_dir.type = FIOS_TYPE_DIRECT; |
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1431 |
switch (_saveload_mode) { |
2639 | 1432 |
case SLD_SAVE_GAME: |
1433 |
case SLD_LOAD_GAME: |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
1434 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR); |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1435 |
break; |
2639 | 1436 |
|
1437 |
case SLD_SAVE_SCENARIO: |
|
1438 |
case SLD_LOAD_SCENARIO: |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
1439 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR); |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1440 |
break; |
2639 | 1441 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1442 |
case SLD_LOAD_HEIGHTMAP: |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
1443 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1444 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1445 |
|
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1446 |
default: |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7371
diff
changeset
|
1447 |
ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name)); |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1448 |
} |
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1449 |
break; |
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1450 |
|
0 | 1451 |
case WE_PAINT: { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1452 |
int pos; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1453 |
int y; |
0 | 1454 |
|
1455 |
SetVScrollCount(w, _fios_num); |
|
1456 |
DrawWindowWidgets(w); |
|
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1457 |
DrawFiosTexts(w->width); |
0 | 1458 |
|
1459 |
if (_savegame_sort_dirty) { |
|
1460 |
_savegame_sort_dirty = false; |
|
1461 |
MakeSortedSaveGameList(); |
|
1462 |
} |
|
1463 |
||
2750
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1464 |
GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7); |
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1465 |
DoDrawString( |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1466 |
_savegame_sort_order & SORT_DESCENDING ? DOWNARROW : UPARROW, |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1467 |
_savegame_sort_order & SORT_BY_NAME ? w->widget[2].right - 9 : w->widget[3].right - 9, |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1468 |
15, 16 |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1469 |
); |
0 | 1470 |
|
2750
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1471 |
y = w->widget[7].top + 1; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1472 |
for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
4171 | 1473 |
const FiosItem *item = _fios_list + pos; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1474 |
|
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2100
diff
changeset
|
1475 |
DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18); |
2549 | 1476 |
y += 10; |
2750
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1477 |
if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
0 | 1478 |
} |
1479 |
||
1480 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6977
diff
changeset
|
1481 |
DrawEditBox(w, &WP(w, querystr_d), 10); |
0 | 1482 |
} |
1483 |
break; |
|
1484 |
} |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1485 |
|
0 | 1486 |
case WE_CLICK: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1487 |
switch (e->we.click.widget) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1488 |
case 2: // Sort save names by name |
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1489 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ? |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1490 |
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
0 | 1491 |
_savegame_sort_dirty = true; |
1492 |
SetWindowDirty(w); |
|
1493 |
break; |
|
1494 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1495 |
case 3: // Sort save names by date |
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1496 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ? |
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
1497 |
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
0 | 1498 |
_savegame_sort_dirty = true; |
1499 |
SetWindowDirty(w); |
|
1500 |
break; |
|
1501 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1502 |
case 6: // OpenTTD 'button', jumps to OpenTTD directory |
2750
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1503 |
FiosBrowseTo(&o_dir); |
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1504 |
SetWindowDirty(w); |
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1505 |
BuildFileList(); |
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1506 |
break; |
f003e561f4b9
(svn r3295) - Regressionfix: scrolling with mousewheel no longer worked in saveload dialogs because of restriction that scroller is only active for widget + next widget is scrollbar. Yes, we need a better window system.
Darkvater
parents:
2748
diff
changeset
|
1507 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1508 |
case 7: { // Click the listbox |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1509 |
int y = (e->we.click.pt.y - w->widget[e->we.click.widget].top - 1) / 10; |
0 | 1510 |
char *name; |
1511 |
const FiosItem *file; |
|
1512 |
||
2639 | 1513 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return; |
0 | 1514 |
|
1515 |
file = _fios_list + y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1516 |
|
2639 | 1517 |
name = FiosBrowseTo(file); |
1518 |
if (name != NULL) { |
|
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1519 |
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) { |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1520 |
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD; |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1521 |
|
0 | 1522 |
SetFiosType(file->type); |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1523 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1524 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1525 |
|
0 | 1526 |
DeleteWindow(w); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1527 |
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1528 |
SetFiosType(file->type); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1529 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1530 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1531 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1532 |
DeleteWindow(w); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1533 |
ShowHeightmapLoad(); |
0 | 1534 |
} else { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1535 |
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */ |
3287
720ed37be8c6
(svn r4001) - Add length parameter to FiosMakeSavegameName() and use this function for creating the full path instead of home-brewn snprintf.
Darkvater
parents:
3193
diff
changeset
|
1536 |
ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength); |
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
|
1537 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1538 |
InvalidateWidget(w, 10); |
0 | 1539 |
} |
1540 |
} else { |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1541 |
/* Changed directory, need repaint. */ |
0 | 1542 |
SetWindowDirty(w); |
1543 |
BuildFileList(); |
|
1544 |
} |
|
1545 |
break; |
|
1546 |
} |
|
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1547 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1548 |
case 11: case 12: // Delete, Save game |
0 | 1549 |
break; |
1550 |
} |
|
1551 |
break; |
|
1552 |
case WE_MOUSELOOP: |
|
5230
660ae3a1ec4c
(svn r7350) -Fix: do not handle the save game/scenario filename edit box when loading a game/scenario/heightmap.
rubidium
parents:
5167
diff
changeset
|
1553 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
660ae3a1ec4c
(svn r7350) -Fix: do not handle the save game/scenario filename edit box when loading a game/scenario/heightmap.
rubidium
parents:
5167
diff
changeset
|
1554 |
HandleEditBox(w, &WP(w, querystr_d), 10); |
660ae3a1ec4c
(svn r7350) -Fix: do not handle the save game/scenario filename edit box when loading a game/scenario/heightmap.
rubidium
parents:
5167
diff
changeset
|
1555 |
} |
0 | 1556 |
break; |
1557 |
case WE_KEYPRESS: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1558 |
if (e->we.keypress.keycode == WKC_ESC) { |
2165
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1559 |
DeleteWindow(w); |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1560 |
return; |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1561 |
} |
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1562 |
|
5729e4207de5
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1563 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1564 |
if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) // Press Enter |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1565 |
HandleButtonClick(w, 12); |
0 | 1566 |
} |
1567 |
break; |
|
1568 |
case WE_TIMEOUT: |
|
5039
ff17ca5e7c3d
(svn r7083) -Fix 6631: Protect out of boundaries widget testing
belugas
parents:
5038
diff
changeset
|
1569 |
/* This test protects against using widgets 11 and 12 which are only available |
ff17ca5e7c3d
(svn r7083) -Fix 6631: Protect out of boundaries widget testing
belugas
parents:
5038
diff
changeset
|
1570 |
* in those two saveload mode */ |
ff17ca5e7c3d
(svn r7083) -Fix 6631: Protect out of boundaries widget testing
belugas
parents:
5038
diff
changeset
|
1571 |
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break; |
ff17ca5e7c3d
(svn r7083) -Fix 6631: Protect out of boundaries widget testing
belugas
parents:
5038
diff
changeset
|
1572 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1573 |
if (IsWindowWidgetLowered(w, 11)) { // Delete button clicked |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6977
diff
changeset
|
1574 |
if (!FiosDelete(WP(w, querystr_d).text.buf)) { |
2255
ddcaf9e333ff
(svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents:
2201
diff
changeset
|
1575 |
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
3288
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1576 |
} else { |
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1577 |
BuildFileList(); |
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1578 |
/* Reset file name to current date on successfull delete */ |
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1579 |
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName(); |
2255
ddcaf9e333ff
(svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents:
2201
diff
changeset
|
1580 |
} |
3288
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1581 |
|
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1582 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
0 | 1583 |
SetWindowDirty(w); |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1584 |
} else if (IsWindowWidgetLowered(w, 12)) { // Save button clicked |
0 | 1585 |
_switch_mode = SM_SAVE; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6977
diff
changeset
|
1586 |
FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name)); |
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1587 |
|
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1588 |
/* 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
|
1589 |
if (_game_mode == GM_EDITOR) StartupEngines(); |
0 | 1590 |
} |
1591 |
break; |
|
1592 |
case WE_DESTROY: |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1593 |
/* pause is only used in single-player, non-editor mode, non menu mode */ |
2952 | 1594 |
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
|
1595 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
2952 | 1596 |
} |
0 | 1597 |
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
|
1598 |
CLRBIT(_no_scroll, SCROLL_SAVE); |
0 | 1599 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1600 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1601 |
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1602 |
uint diff = e->we.sizing.diff.x / 2; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1603 |
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
|
1604 |
w->widget[3].left += diff; |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1605 |
w->widget[3].right += e->we.sizing.diff.x; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1606 |
|
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1607 |
/* Same for widget 11 and 12 in save-dialog */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1608 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1609 |
w->widget[11].right += diff; |
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1610 |
w->widget[12].left += diff; |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1611 |
w->widget[12].right += e->we.sizing.diff.x; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1612 |
} |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1613 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1614 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1615 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1616 |
} |
0 | 1617 |
} |
1618 |
||
1619 |
static const WindowDesc _load_dialog_desc = { |
|
1620 |
WDP_CENTER, WDP_CENTER, 257, 294, |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1621 |
WC_SAVELOAD, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1622 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1623 |
_load_dialog_widgets, |
0 | 1624 |
SaveLoadDlgWndProc, |
1625 |
}; |
|
1626 |
||
1627 |
static const WindowDesc _save_dialog_desc = { |
|
1628 |
WDP_CENTER, WDP_CENTER, 257, 320, |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1629 |
WC_SAVELOAD, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1630 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1631 |
_save_dialog_widgets, |
1632 |
SaveLoadDlgWndProc, |
|
1633 |
}; |
|
1634 |
||
1635 |
void ShowSaveLoadDialog(int mode) |
|
1636 |
{ |
|
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1637 |
static const StringID saveload_captions[] = { |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1638 |
STR_4001_LOAD_GAME, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1639 |
STR_0298_LOAD_SCENARIO, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1640 |
STR_4000_SAVE_GAME, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1641 |
STR_0299_SAVE_SCENARIO, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1642 |
STR_4011_LOAD_HEIGHTMAP, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1643 |
}; |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1644 |
|
0 | 1645 |
Window *w; |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1646 |
const WindowDesc *sld = &_save_dialog_desc; |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1647 |
|
0 | 1648 |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1649 |
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0); |
0 | 1650 |
DeleteWindowById(WC_QUERY_STRING, 0); |
1651 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1652 |
||
1653 |
_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
|
1654 |
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
|
1655 |
|
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
|
1656 |
switch (mode) { |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1657 |
case SLD_SAVE_GAME: GenerateFileName(); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1658 |
case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1659 |
default: sld = &_load_dialog_desc; break; |
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
|
1660 |
} |
0 | 1661 |
|
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1662 |
assert((uint)mode < lengthof(saveload_captions)); |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1663 |
w = AllocateWindowDesc(sld); |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1664 |
w->widget[1].data = saveload_captions[mode]; |
0 | 1665 |
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
|
1666 |
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
|
1667 |
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
|
1668 |
w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4672
diff
changeset
|
1669 |
LowerWindowWidget(w, 7); |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1670 |
|
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1671 |
WP(w, querystr_d).afilter = CS_ALPHANUMERAL; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1672 |
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240); |
0 | 1673 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1674 |
/* pause is only used in single-player, non-editor mode, non-menu mode. It |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1675 |
* will be unpaused in the WE_DESTROY event handler. */ |
2639 | 1676 |
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
|
1677 |
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
2639 | 1678 |
} |
278
950c3ac6e649
(svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents:
258
diff
changeset
|
1679 |
|
0 | 1680 |
BuildFileList(); |
1681 |
||
1682 |
ResetObjectToPlace(); |
|
1683 |
} |
|
1684 |
||
6573 | 1685 |
void RedrawAutosave() |
0 | 1686 |
{ |
1687 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
|
1688 |
} |
|
1689 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1690 |
void SetFiosType(const byte fiostype) |
0 | 1691 |
{ |
1692 |
switch (fiostype) { |
|
2549 | 1693 |
case FIOS_TYPE_FILE: |
1694 |
case FIOS_TYPE_SCENARIO: |
|
1695 |
_file_to_saveload.mode = SL_LOAD; |
|
1696 |
break; |
|
1697 |
||
1698 |
case FIOS_TYPE_OLDFILE: |
|
1699 |
case FIOS_TYPE_OLD_SCENARIO: |
|
1700 |
_file_to_saveload.mode = SL_OLD_LOAD; |
|
1701 |
break; |
|
1702 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1703 |
#ifdef WITH_PNG |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1704 |
case FIOS_TYPE_PNG: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1705 |
_file_to_saveload.mode = SL_PNG; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1706 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1707 |
#endif /* WITH_PNG */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1708 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1709 |
case FIOS_TYPE_BMP: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1710 |
_file_to_saveload.mode = SL_BMP; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1711 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1712 |
|
2549 | 1713 |
default: |
1714 |
_file_to_saveload.mode = SL_INVALID; |
|
1715 |
break; |
|
0 | 1716 |
} |
1717 |
} |
|
1718 |
||
410 | 1719 |
static int32 ClickMoneyCheat(int32 p1, int32 p2) |
0 | 1720 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1721 |
DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT); |
0 | 1722 |
return true; |
1723 |
} |
|
1724 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1725 |
/** |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1726 |
* @param p1 player to set to |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1727 |
* @param p2 is -1 or +1 (down/up) |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1728 |
*/ |
410 | 1729 |
static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
0 | 1730 |
{ |
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4834
diff
changeset
|
1731 |
while (IsValidPlayer((PlayerID)p1)) { |
2639 | 1732 |
if (_players[p1].is_active) { |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5355
diff
changeset
|
1733 |
SetLocalPlayer((PlayerID)p1); |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5355
diff
changeset
|
1734 |
|
138
6ab4d97d1034
(svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents:
108
diff
changeset
|
1735 |
MarkWholeScreenDirty(); |
0 | 1736 |
return _local_player; |
1737 |
} |
|
1738 |
p1 += p2; |
|
1739 |
} |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1740 |
|
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1741 |
return _local_player; |
0 | 1742 |
} |
1743 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1744 |
/** |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1745 |
* @param p1 -1 or +1 (down/up) |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
1746 |
* @param p2 unused |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1747 |
*/ |
1095 | 1748 |
static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
100 | 1749 |
{ |
2639 | 1750 |
if (p1 == -1) p1 = 3; |
1751 |
if (p1 == 4) p1 = 0; |
|
100 | 1752 |
_opt.landscape = p1; |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
1753 |
ReloadNewGRFData(); |
100 | 1754 |
return _opt.landscape; |
1755 |
} |
|
1756 |
||
6573 | 1757 |
extern void EnginesMonthlyLoop(); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1758 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1759 |
/** |
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6949
diff
changeset
|
1760 |
* @param p1 unused |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1761 |
* @param p2 1 (increase) or -1 (decrease) |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1762 |
*/ |
1095 | 1763 |
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
|
1764 |
{ |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1765 |
YearMonthDay ymd; |
4288
60398d0e64ee
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
1766 |
ConvertDateToYMD(_date, &ymd); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1767 |
|
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
1768 |
if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year; |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1769 |
|
4288
60398d0e64ee
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
1770 |
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1771 |
EnginesMonthlyLoop(); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1772 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1773 |
return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1774 |
} |
100 | 1775 |
|
0 | 1776 |
typedef int32 CheckButtonClick(int32, int32); |
1777 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1778 |
enum ce_flags_long |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1779 |
{ |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1780 |
CE_NONE = 0, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1781 |
CE_CLICK = 1 << 0, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1782 |
CE_END = 1 << 1, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1783 |
}; |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1784 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1785 |
/** Define basic enum properties */ |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1786 |
template <> struct EnumPropsT<ce_flags_long> : MakeEnumPropsT<ce_flags_long, byte, CE_NONE, CE_END, CE_END> {}; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1787 |
typedef TinyEnumT<ce_flags_long> ce_flags; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1788 |
|
1345
5cb0e0eda22d
(svn r1849) Use the cheat entry enum for CheatEntry.type and remove unused enum values
tron
parents:
1344
diff
changeset
|
1789 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
1790 |
struct CheatEntry { |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1791 |
VarType type; ///< type of selector |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1792 |
ce_flags flags; ///< selector flags |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1793 |
StringID str; ///< string with descriptive text |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1794 |
void *variable; ///< pointer to the variable |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1795 |
bool *been_used; ///< has this cheat been used before? |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1796 |
CheckButtonClick *proc;///< procedure |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1797 |
int16 min, max; ///< range for spinbox setting |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
1798 |
}; |
0 | 1799 |
|
1800 |
static const CheatEntry _cheats_ui[] = { |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1801 |
{SLE_BOOL, {CE_CLICK}, STR_CHEAT_MONEY, &_cheats.money.value, &_cheats.money.been_used, &ClickMoneyCheat, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1802 |
{SLE_UINT8, {CE_NONE}, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat, 0, 11}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1803 |
{SLE_BOOL, {CE_NONE}, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1804 |
{SLE_BOOL, {CE_NONE}, STR_CHEAT_CROSSINGTUNNELS,&_cheats.crossing_tunnels.value,&_cheats.crossing_tunnels.been_used,NULL, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1805 |
{SLE_BOOL, {CE_NONE}, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1806 |
{SLE_BOOL, {CE_NONE}, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1807 |
{SLE_BOOL, {CE_NONE}, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL, 0, 0}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1808 |
{SLE_UINT8, {CE_NONE}, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat,-1, 4}, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1809 |
{SLE_INT32, {CE_NONE}, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1}, |
0 | 1810 |
}; |
1811 |
||
1812 |
||
1813 |
static const Widget _cheat_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1814 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1815 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1816 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1817 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 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
|
1818 |
{ WIDGETS_END}, |
0 | 1819 |
}; |
1820 |
||
1821 |
static void CheatsWndProc(Window *w, WindowEvent *e) |
|
1822 |
{ |
|
2639 | 1823 |
switch (e->event) { |
0 | 1824 |
case WE_PAINT: { |
1825 |
int clk = WP(w,def_d).data_1; |
|
1826 |
int x, y; |
|
1827 |
int i; |
|
1828 |
||
1829 |
DrawWindowWidgets(w); |
|
1830 |
||
6523
d41352ca5c1e
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
6516
diff
changeset
|
1831 |
DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50); |
0 | 1832 |
|
2639 | 1833 |
x = 0; |
1834 |
y = 45; |
|
0 | 1835 |
|
2639 | 1836 |
for (i = 0; i != lengthof(_cheats_ui); i++) { |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1837 |
const CheatEntry *ce = &_cheats_ui[i]; |
2639 | 1838 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5890
diff
changeset
|
1839 |
DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, x + 5, y + 2); |
0 | 1840 |
|
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1841 |
switch (ce->type) { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1842 |
case SLE_BOOL: { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1843 |
bool on = (*(bool*)ce->variable); |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1844 |
|
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1845 |
if (ce->flags & CE_CLICK) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1846 |
DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, 0, (clk - (i * 2) == 1) ? FR_LOWERED : FR_NONE); |
3193
d151574ef3cf
(svn r3853) - Fix a change of SetDParam64 to SetDParam in r3713 that caused slightly vibrating text when pressing the cheat-button. Thanks to peter1138 for noticing.
Darkvater
parents:
3110
diff
changeset
|
1847 |
if (i == 0) { // XXX - hack/hack for first element which is increase money. Told ya it's a mess |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7494
diff
changeset
|
1848 |
SetDParam(0, 10000000); |
3193
d151574ef3cf
(svn r3853) - Fix a change of SetDParam64 to SetDParam in r3713 that caused slightly vibrating text when pressing the cheat-button. Thanks to peter1138 for noticing.
Darkvater
parents:
3110
diff
changeset
|
1849 |
} else { |
d151574ef3cf
(svn r3853) - Fix a change of SetDParam64 to SetDParam in r3713 that caused slightly vibrating text when pressing the cheat-button. Thanks to peter1138 for noticing.
Darkvater
parents:
3110
diff
changeset
|
1850 |
SetDParam(0, false); |
d151574ef3cf
(svn r3853) - Fix a change of SetDParam64 to SetDParam in r3713 that caused slightly vibrating text when pressing the cheat-button. Thanks to peter1138 for noticing.
Darkvater
parents:
3110
diff
changeset
|
1851 |
} |
2639 | 1852 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1853 |
DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, on ? 6 : 4, on ? FR_LOWERED : FR_NONE); |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1854 |
SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
2639 | 1855 |
} |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1856 |
} break; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1857 |
default: { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1858 |
int32 val = (int32)ReadValue(ce->variable, ce->type); |
3589
e9cfae73fd0c
(svn r4478) -Fix (FS#107) In the cheat menu, don't hard-code the player icon, but compute its position from the length of the string.
celestar
parents:
3491
diff
changeset
|
1859 |
char buf[512]; |
2639 | 1860 |
|
3107
a6406bbecd3d
(svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.
Darkvater
parents:
2952
diff
changeset
|
1861 |
/* Draw [<][>] boxes for settings of an integer-type */ |
4211
d8c4c40eba62
(svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents:
4171
diff
changeset
|
1862 |
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1863 |
|
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1864 |
switch (ce->str) { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1865 |
/* Display date for change date cheat */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1866 |
case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1867 |
/* Draw colored flag for change player cheat */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1868 |
case STR_CHEAT_CHANGE_PLAYER: |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1869 |
SetDParam(0, val); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1870 |
GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf)); |
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4558
diff
changeset
|
1871 |
DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2); |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1872 |
break; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1873 |
/* Set correct string for switch climate cheat */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1874 |
case STR_CHEAT_SWITCH_CLIMATE: val += STR_TEMPERATE_LANDSCAPE; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1875 |
/* Fallthrough */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1876 |
default: SetDParam(0, val); |
2639 | 1877 |
} |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1878 |
} break; |
0 | 1879 |
} |
1880 |
||
2639 | 1881 |
DrawString(50, y + 1, ce->str, 0); |
0 | 1882 |
|
2639 | 1883 |
y += 12; |
0 | 1884 |
} |
1885 |
break; |
|
1886 |
} |
|
2639 | 1887 |
|
0 | 1888 |
case WE_CLICK: { |
1889 |
const CheatEntry *ce; |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1890 |
uint btn = (e->we.click.pt.y - 46) / 12; |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1891 |
int32 value, oldvalue; |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1892 |
uint x = e->we.click.pt.x; |
0 | 1893 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1894 |
/* not clicking a button? */ |
2639 | 1895 |
if (!IS_INT_INSIDE(x, 20, 40) || btn >= lengthof(_cheats_ui)) break; |
0 | 1896 |
|
1897 |
ce = &_cheats_ui[btn]; |
|
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1898 |
oldvalue = value = (int32)ReadValue(ce->variable, ce->type); |
0 | 1899 |
|
1900 |
*ce->been_used = true; |
|
1901 |
||
2639 | 1902 |
switch (ce->type) { |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1903 |
case SLE_BOOL: |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1904 |
if (ce->flags & CE_CLICK) WP(w,def_d).data_1 = btn * 2 + 1; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1905 |
value ^= 1; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1906 |
if (ce->proc != NULL) ce->proc(value, 0); |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1907 |
break; |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1908 |
default: { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1909 |
/* Add a dynamic step-size to the scroller. In a maximum of |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1910 |
* 50-steps you should be able to get from min to max */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1911 |
uint16 step = ((ce->max - ce->min) / 20); |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1912 |
if (step == 0) step = 1; |
0 | 1913 |
|
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1914 |
/* Increase or decrease the value and clamp it to extremes */ |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1915 |
value += (x >= 30) ? step : -step; |
5981
7aa1a23cd1e4
(svn r8273) -Fix: return value from clamp was ignored
KUDr
parents:
5977
diff
changeset
|
1916 |
value = clamp(value, ce->min, ce->max); |
0 | 1917 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1918 |
/* take whatever the function returns */ |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1919 |
value = ce->proc(value, (x >= 30) ? 1 : -1); |
0 | 1920 |
|
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1921 |
if (value != oldvalue) { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1922 |
WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); |
0 | 1923 |
} |
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1924 |
} break; |
0 | 1925 |
} |
1926 |
||
3110
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1927 |
if (value != oldvalue) { |
92181a7f9b7d
(svn r3713) - Fix up the cheats window a little. The cheats code is still abominable, but at least a bit more readable now.
Darkvater
parents:
3107
diff
changeset
|
1928 |
WriteValue(ce->variable, ce->type, (int64)value); |
0 | 1929 |
SetWindowDirty(w); |
1930 |
} |
|
1931 |
||
1932 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
1933 |
||
1934 |
SetWindowDirty(w); |
|
1935 |
} |
|
1936 |
break; |
|
1937 |
case WE_TIMEOUT: |
|
1938 |
WP(w,def_d).data_1 = 0; |
|
1939 |
SetWindowDirty(w); |
|
1940 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1941 |
} |
0 | 1942 |
} |
2639 | 1943 |
|
0 | 1944 |
static const WindowDesc _cheats_desc = { |
3890
f8f13a91446a
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents:
3798
diff
changeset
|
1945 |
240, 22, 400, 170, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1946 |
WC_CHEATS, WC_NONE, |
0 | 1947 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1948 |
_cheat_widgets, |
|
1949 |
CheatsWndProc |
|
1950 |
}; |
|
1951 |
||
1952 |
||
6573 | 1953 |
void ShowCheatWindow() |
0 | 1954 |
{ |
1955 |
DeleteWindowById(WC_CHEATS, 0); |
|
5137
a1f26c30fecd
(svn r7219) -Fix: Several warnings by gcc introduced in r7206 which MSVC found not of a problem. Thanks Tron
Darkvater
parents:
5125
diff
changeset
|
1956 |
AllocateWindowDesc(&_cheats_desc); |
0 | 1957 |
} |