author | rubidium |
Mon, 31 Mar 2008 00:06:17 +0000 | |
changeset 8785 | 871586967963 |
parent 8748 | 72c372800b54 |
child 8787 | 41d9d5adbe87 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
3 |
/** @file misc_gui.cpp */ |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1879
diff
changeset
|
6 |
#include "openttd.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
7 |
#include "heightmap.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1274
diff
changeset
|
8 |
#include "debug.h" |
6453
226bcddeba32
(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:
6350
diff
changeset
|
9 |
#include "landscape.h" |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
10 |
#include "newgrf.h" |
7750
7afbef1235e0
(svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents:
7521
diff
changeset
|
11 |
#include "newgrf_text.h" |
2162
b98e430ffd10
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
2159
diff
changeset
|
12 |
#include "saveload.h" |
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
8107
diff
changeset
|
13 |
#include "tile_map.h" |
0 | 14 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
15 |
#include "window_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
16 |
#include "station_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
17 |
#include "textbuf_gui.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
18 |
#include "viewport_func.h" |
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
19 |
#include "gfx_func.h" |
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8748
diff
changeset
|
20 |
#include "station_func.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
21 |
#include "command_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
22 |
#include "player_func.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
23 |
#include "player_base.h" |
0 | 24 |
#include "town.h" |
5469
7edfc643abbc
(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:
5447
diff
changeset
|
25 |
#include "network/network.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2134
diff
changeset
|
26 |
#include "variables.h" |
3890
e04bc34bc50c
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents:
3798
diff
changeset
|
27 |
#include "train.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
28 |
#include "tgp.h" |
6091
c8827d9ae04a
(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:
5893
diff
changeset
|
29 |
#include "cargotype.h" |
6190
01a2b579b668
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6091
diff
changeset
|
30 |
#include "player_face.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8108
diff
changeset
|
31 |
#include "strings_func.h" |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6875
diff
changeset
|
32 |
#include "fileio.h" |
4223
d4c9ef555f43
(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
|
33 |
#include "fios.h" |
8119
52b48108425a
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8116
diff
changeset
|
34 |
#include "tile_cmd.h" |
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8121
diff
changeset
|
35 |
#include "zoom_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8123
diff
changeset
|
36 |
#include "functions.h" |
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8123
diff
changeset
|
37 |
#include "window_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8139
diff
changeset
|
38 |
#include "date_func.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8152
diff
changeset
|
39 |
#include "sound_func.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8208
diff
changeset
|
40 |
#include "string_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
41 |
#include "player_gui.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
42 |
#include "settings_type.h" |
8119
52b48108425a
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8116
diff
changeset
|
43 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
44 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
45 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
46 |
#include "table/tree_land.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
47 |
|
4223
d4c9ef555f43
(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
|
48 |
/* Variables to display file lists */ |
d4c9ef555f43
(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
|
49 |
FiosItem *_fios_list; |
8149
1b1390cb0844
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents:
8144
diff
changeset
|
50 |
SaveLoadDialogMode _saveload_mode; |
0 | 51 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
52 |
|
1596
483007886b59
(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
|
53 |
static bool _fios_path_changed; |
1594
00485cb74836
(svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents:
1578
diff
changeset
|
54 |
static bool _savegame_sort_dirty; |
00485cb74836
(svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents:
1578
diff
changeset
|
55 |
|
5583
136d8764c7e6
(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:
5475
diff
changeset
|
56 |
enum { |
136d8764c7e6
(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:
5475
diff
changeset
|
57 |
LAND_INFO_LINES = 7, |
136d8764c7e6
(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:
5475
diff
changeset
|
58 |
LAND_INFO_LINE_BUFF_SIZE = 512, |
136d8764c7e6
(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:
5475
diff
changeset
|
59 |
}; |
136d8764c7e6
(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:
5475
diff
changeset
|
60 |
|
136d8764c7e6
(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:
5475
diff
changeset
|
61 |
static char _landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE]; |
0 | 62 |
|
63 |
static void LandInfoWndProc(Window *w, WindowEvent *e) |
|
64 |
{ |
|
65 |
if (e->event == WE_PAINT) { |
|
66 |
DrawWindowWidgets(w); |
|
67 |
||
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
68 |
DoDrawStringCentered(140, 16, _landinfo_data[0], TC_LIGHT_BLUE); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
69 |
DoDrawStringCentered(140, 27, _landinfo_data[1], TC_FROMSTRING); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
70 |
DoDrawStringCentered(140, 38, _landinfo_data[2], TC_FROMSTRING); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
71 |
DoDrawStringCentered(140, 49, _landinfo_data[3], TC_FROMSTRING); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
72 |
DoDrawStringCentered(140, 60, _landinfo_data[4], TC_FROMSTRING); |
6197
558f3a9b5bd4
(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:
6190
diff
changeset
|
73 |
if (_landinfo_data[5][0] != '\0') DrawStringMultiCenter(140, 76, BindCString(_landinfo_data[5]), w->width - 4); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
74 |
if (_landinfo_data[6][0] != '\0') DoDrawStringCentered(140, 71, _landinfo_data[6], TC_FROMSTRING); |
0 | 75 |
} |
76 |
} |
|
77 |
||
78 |
static const Widget _land_info_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
79 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
80 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
81 |
{ 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
|
82 |
{ WIDGETS_END}, |
0 | 83 |
}; |
84 |
||
85 |
static const WindowDesc _land_info_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
86 |
WDP_AUTO, WDP_AUTO, 280, 93, 280, 93, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
87 |
WC_LAND_INFO, WC_NONE, |
0 | 88 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
89 |
_land_info_widgets, |
|
90 |
LandInfoWndProc |
|
91 |
}; |
|
92 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
93 |
static void Place_LandInfo(TileIndex tile) |
0 | 94 |
{ |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
95 |
AcceptedCargo ac; |
136d8764c7e6
(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:
5475
diff
changeset
|
96 |
TileDesc td; |
0 | 97 |
|
98 |
DeleteWindowById(WC_LAND_INFO, 0); |
|
99 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
100 |
Window *w = AllocateWindowDesc(&_land_info_desc); |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
101 |
WP(w, void_d).data = &_landinfo_data; |
0 | 102 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
103 |
Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
104 |
Town *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 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
106 |
Money old_money = p->player_money; |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6953
diff
changeset
|
107 |
p->player_money = INT64_MAX; |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
108 |
CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR); |
6952
b19643469024
(svn r10207) -Codechange: remove the redundant player_money in favour of the money64, which is now renamed to player_money.
rubidium
parents:
6950
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 |
|
5583
136d8764c7e6
(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:
5475
diff
changeset
|
111 |
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */ |
136d8764c7e6
(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:
5475
diff
changeset
|
112 |
td.build_date = 0; |
136d8764c7e6
(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:
5475
diff
changeset
|
113 |
GetAcceptedCargo(tile, ac); |
136d8764c7e6
(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:
5475
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 |
|
5583
136d8764c7e6
(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:
5475
diff
changeset
|
116 |
SetDParam(0, td.dparam[0]); |
136d8764c7e6
(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:
5475
diff
changeset
|
117 |
GetString(_landinfo_data[0], td.str, lastof(_landinfo_data[0])); |
136d8764c7e6
(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:
5475
diff
changeset
|
118 |
|
136d8764c7e6
(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:
5475
diff
changeset
|
119 |
SetDParam(0, STR_01A6_N_A); |
136d8764c7e6
(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:
5475
diff
changeset
|
120 |
if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile); |
136d8764c7e6
(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:
5475
diff
changeset
|
121 |
GetString(_landinfo_data[1], STR_01A7_OWNER, lastof(_landinfo_data[1])); |
136d8764c7e6
(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:
5475
diff
changeset
|
122 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
123 |
StringID str = STR_01A4_COST_TO_CLEAR_N_A; |
6946
a48b23f1cc8a
(svn r10200) -Codechange: add "shortcut" for !CmdFailed (CmdSucceeded).
rubidium
parents:
6929
diff
changeset
|
124 |
if (CmdSucceeded(costclear)) { |
7002
1bf6a62b0fcb
(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:
6998
diff
changeset
|
125 |
SetDParam(0, costclear.GetCost()); |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
126 |
str = STR_01A5_COST_TO_CLEAR; |
136d8764c7e6
(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:
5475
diff
changeset
|
127 |
} |
136d8764c7e6
(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:
5475
diff
changeset
|
128 |
GetString(_landinfo_data[2], str, lastof(_landinfo_data[2])); |
136d8764c7e6
(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:
5475
diff
changeset
|
129 |
|
136d8764c7e6
(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:
5475
diff
changeset
|
130 |
snprintf(_userstring, lengthof(_userstring), "0x%.4X", tile); |
136d8764c7e6
(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:
5475
diff
changeset
|
131 |
SetDParam(0, TileX(tile)); |
136d8764c7e6
(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:
5475
diff
changeset
|
132 |
SetDParam(1, TileY(tile)); |
7438
991f20e5bc77
(svn r10878) -Add [FS#653]: added TileHeight to the Land Area Information tool (blove)
truelight
parents:
7386
diff
changeset
|
133 |
SetDParam(2, TileHeight(tile)); |
991f20e5bc77
(svn r10878) -Add [FS#653]: added TileHeight to the Land Area Information tool (blove)
truelight
parents:
7386
diff
changeset
|
134 |
SetDParam(3, STR_SPEC_USERSTRING); |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
135 |
GetString(_landinfo_data[3], STR_LANDINFO_COORDS, lastof(_landinfo_data[3])); |
136d8764c7e6
(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:
5475
diff
changeset
|
136 |
|
136d8764c7e6
(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:
5475
diff
changeset
|
137 |
SetDParam(0, STR_01A9_NONE); |
7386
93f6a042d1c3
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7372
diff
changeset
|
138 |
if (t != NULL && t->IsValid()) { |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
139 |
SetDParam(0, STR_TOWN); |
136d8764c7e6
(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:
5475
diff
changeset
|
140 |
SetDParam(1, t->index); |
136d8764c7e6
(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:
5475
diff
changeset
|
141 |
} |
136d8764c7e6
(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:
5475
diff
changeset
|
142 |
GetString(_landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(_landinfo_data[4])); |
136d8764c7e6
(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:
5475
diff
changeset
|
143 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
144 |
char *strp = GetString(_landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(_landinfo_data[5])); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
145 |
bool found = false; |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
146 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
147 |
for (CargoID i = 0; i < NUM_CARGO; ++i) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
148 |
if (ac[i] > 0) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
149 |
/* Add a comma between each item. */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
150 |
if (found) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
151 |
*strp++ = ','; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
152 |
*strp++ = ' '; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
153 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
154 |
found = true; |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
155 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
156 |
/* If the accepted value is less than 8, show it in 1/8:ths */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
157 |
if (ac[i] < 8) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
158 |
SetDParam(0, ac[i]); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
159 |
SetDParam(1, GetCargo(i)->name); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
160 |
strp = GetString(strp, STR_01D1_8, lastof(_landinfo_data[5])); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
161 |
} else { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
162 |
strp = GetString(strp, GetCargo(i)->name, lastof(_landinfo_data[5])); |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
163 |
} |
136d8764c7e6
(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:
5475
diff
changeset
|
164 |
} |
136d8764c7e6
(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:
5475
diff
changeset
|
165 |
} |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
166 |
if (!found) _landinfo_data[5][0] = '\0'; |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
167 |
|
136d8764c7e6
(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:
5475
diff
changeset
|
168 |
if (td.build_date != 0) { |
136d8764c7e6
(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:
5475
diff
changeset
|
169 |
SetDParam(0, td.build_date); |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
170 |
GetString(_landinfo_data[6], STR_BUILD_DATE, lastof(_landinfo_data[6])); |
5583
136d8764c7e6
(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:
5475
diff
changeset
|
171 |
} else { |
136d8764c7e6
(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:
5475
diff
changeset
|
172 |
_landinfo_data[6][0] = '\0'; |
136d8764c7e6
(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:
5475
diff
changeset
|
173 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
174 |
|
4000
4009d092b306
(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
|
175 |
#if defined(_DEBUG) |
4009d092b306
(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
|
176 |
# define LANDINFOD_LEVEL 0 |
4009d092b306
(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 |
#else |
4009d092b306
(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 1 |
4009d092b306
(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 |
#endif |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
180 |
DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
181 |
DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
182 |
DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
183 |
DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
184 |
DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
185 |
DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4); |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5376
diff
changeset
|
186 |
DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5); |
5596
5bf7128140a0
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5587
diff
changeset
|
187 |
DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _m[tile].m6); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6248
diff
changeset
|
188 |
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7); |
4000
4009d092b306
(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
|
189 |
#undef LANDINFOD_LEVEL |
0 | 190 |
} |
191 |
||
6247 | 192 |
void PlaceLandBlockInfo() |
0 | 193 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
194 |
if (_cursor.sprite == SPR_CURSOR_QUERY) { |
0 | 195 |
ResetObjectToPlace(); |
196 |
} else { |
|
197 |
_place_proc = Place_LandInfo; |
|
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7859
diff
changeset
|
198 |
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0); |
0 | 199 |
} |
200 |
} |
|
201 |
||
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
202 |
static const char *credits[] = { |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
203 |
/************************************************************************* |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
204 |
* maximum length of string which fits in window -^*/ |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
205 |
"Original design by Chris Sawyer", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
206 |
"Original graphics by Simon Foster", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
207 |
"", |
1124 | 208 |
"The OpenTTD team (in alphabetical order):", |
8059
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
209 |
" Jean-Francois Claeys (Belugas) - GUI, newindustries and more", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
210 |
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
211 |
" Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
212 |
" Loïc Guilloux (glx) - General coding", |
8623
fc7590c9657c
(svn r12206) -Fix: A comma is not a rare resource. Do not hesitate to use it when needed.
belugas
parents:
8605
diff
changeset
|
213 |
" Christoph Elsenhans (frosch) - General coding", |
5355
195bce6def67
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
214 |
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
6239 | 215 |
" Jonathan Coome (Maedhros) - High priest of the newGRF Temple", |
5108
aeaef6fe53b7
(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
|
216 |
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host", |
7074
e9ac73a61934
(svn r10339) -Fix r10311: if you fix your own name, at least also update your description ;)
truelight
parents:
7058
diff
changeset
|
217 |
" Owen Rudge (orudge) - Forum host, OS/2 port", |
8184
01844847278c
(svn r11747) -Change: Return of the prodigal son (or something). Little update (but highly noticed) on the OpenTTD Team
belugas
parents:
8157
diff
changeset
|
218 |
" Peter Nelson (peter1138) - Spiritual descendant from newGRF gods", |
8059
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
219 |
" Remko Bijker (Rubidium) - Lead coder and way more", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
220 |
" Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
221 |
" Zdenek Sojka (SmatZ) - Bug finder and fixer", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
222 |
"", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
223 |
"Inactive Developers:", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
224 |
" Victor Fischer (Celestar) - Programming everywhere you need him to", |
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
225 |
" Tamás Faragó (Darkvater) - Ex-Lead coder", |
1126 | 226 |
" Christoph Mallon (Tron) - Programmer, code correctness police", |
1125 | 227 |
"", |
228 |
"Retired Developers:", |
|
229 |
" Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)", |
|
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
230 |
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
1826
6000a1a8e448
(svn r2331) - Fix (regression): fix text overflows in about box.
Darkvater
parents:
1821
diff
changeset
|
231 |
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)", |
7859
5595fe36e31b
(svn r11409) -Update: as of now, I am a retired Developer, so mark me as such
truelight
parents:
7824
diff
changeset
|
232 |
" Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)", |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
233 |
"", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
234 |
"Special thanks go out to:", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
235 |
" Josef Drexler - For his great work on TTDPatch", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
236 |
" Marcin Grzegorczyk - For his documentation of TTD internals", |
8059
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
237 |
" Petr Baudis (pasky) - Many patches, newGRF support", |
5108
aeaef6fe53b7
(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
|
238 |
" Stefan Meißner (sign_de) - For his work on the console", |
8059
0dbe702b7096
(svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team
belugas
parents:
8053
diff
changeset
|
239 |
" Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with", |
1124 | 240 |
" Cian Duffy (MYOB) - BeOS port / manual writing", |
4133
f9878fb9a365
(svn r5489) -Fix: corrected tokai's name and morphos details (tokai)
truelight
parents:
4091
diff
changeset
|
241 |
" Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
5355
195bce6def67
(svn r7527) -Update appropiate files with release information for 0.5.0-RC1
Darkvater
parents:
5352
diff
changeset
|
242 |
" Richard Kempton (richK) - additional airports, initial TGP implementation", |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
243 |
"", |
5108
aeaef6fe53b7
(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
|
244 |
" Michael Blunck - Pre-Signals and Semaphores © 2003", |
aeaef6fe53b7
(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
|
245 |
" George - Canal/Lock graphics © 2003-2004", |
6691
f9adbb0be102
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
6670
diff
changeset
|
246 |
" David Dallaston - Tram tracks", |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
247 |
" Marcin Grzegorczyk - Foundations for Tracks on Slopes", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
248 |
" All Translators - Who made OpenTTD a truly international game", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
249 |
" Bug Reporters - Without whom OpenTTD would still be full of bugs!", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
250 |
"", |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
251 |
"", |
1124 | 252 |
"And last but not least:", |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
253 |
" Chris Sawyer - For an amazing game!" |
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
254 |
}; |
0 | 255 |
|
256 |
static void AboutWindowProc(Window *w, WindowEvent *e) |
|
257 |
{ |
|
2639 | 258 |
switch (e->event) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
259 |
case WE_CREATE: // Set up window counter and start position of scroller |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
260 |
WP(w, scroller_d).counter = 5; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
261 |
WP(w, scroller_d).height = w->height - 40; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
262 |
break; |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
263 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
264 |
case WE_PAINT: { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
265 |
int y = WP(w, scroller_d).height; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
266 |
DrawWindowWidgets(w); |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
267 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
268 |
/* Show original copyright and revision version */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
269 |
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
270 |
DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING); |
859
611a03925f9a
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
842
diff
changeset
|
271 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
272 |
/* Show all scrolling credits */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
273 |
for (uint i = 0; i < lengthof(credits); i++) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
274 |
if (y >= 50 && y < (w->height - 40)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
275 |
DoDrawString(credits[i], 10, y, TC_BLACK); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
276 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
277 |
y += 10; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
278 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
279 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
280 |
/* If the last text has scrolled start anew from the start */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
281 |
if (y < 50) WP(w, scroller_d).height = w->height - 40; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
282 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
283 |
DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
284 |
DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
285 |
} break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
286 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
287 |
case WE_TICK: // Timer to scroll the text and adjust the new top |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
288 |
if (--WP(w, scroller_d).counter == 0) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
289 |
WP(w, scroller_d).counter = 5; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
290 |
WP(w, scroller_d).height--; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
291 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
292 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
293 |
break; |
0 | 294 |
} |
295 |
} |
|
296 |
||
297 |
static const Widget _about_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
298 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
299 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
7e123fec5b0b
(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
|
300 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
301 |
{ 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
|
302 |
{ WIDGETS_END}, |
0 | 303 |
}; |
304 |
||
305 |
static const WindowDesc _about_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
306 |
WDP_CENTER, WDP_CENTER, 420, 272, 420, 272, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
307 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 308 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
309 |
_about_widgets, |
|
310 |
AboutWindowProc |
|
311 |
}; |
|
312 |
||
313 |
||
6247 | 314 |
void ShowAboutWindow() |
0 | 315 |
{ |
316 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
317 |
AllocateWindowDesc(&_about_desc); |
|
318 |
} |
|
319 |
||
320 |
static int _tree_to_plant; |
|
321 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
322 |
static const PalSpriteID _tree_sprites[] = { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
323 |
{ 0x655, PAL_NONE }, { 0x663, PAL_NONE }, { 0x678, PAL_NONE }, { 0x62B, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
324 |
{ 0x647, PAL_NONE }, { 0x639, PAL_NONE }, { 0x64E, PAL_NONE }, { 0x632, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
325 |
{ 0x67F, PAL_NONE }, { 0x68D, PAL_NONE }, { 0x69B, PAL_NONE }, { 0x6A9, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
326 |
{ 0x6AF, PAL_NONE }, { 0x6D2, PAL_NONE }, { 0x6D9, PAL_NONE }, { 0x6C4, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
327 |
{ 0x6CB, PAL_NONE }, { 0x6B6, PAL_NONE }, { 0x6BD, PAL_NONE }, { 0x6E0, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
328 |
{ 0x72E, PAL_NONE }, { 0x734, PAL_NONE }, { 0x74A, PAL_NONE }, { 0x74F, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
329 |
{ 0x76B, PAL_NONE }, { 0x78F, PAL_NONE }, { 0x788, PAL_NONE }, { 0x77B, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
330 |
{ 0x75F, PAL_NONE }, { 0x774, PAL_NONE }, { 0x720, PAL_NONE }, { 0x797, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
331 |
{ 0x79E, PAL_NONE }, { 0x7A5, PALETTE_TO_GREEN }, { 0x7AC, PALETTE_TO_RED }, { 0x7B3, PAL_NONE }, |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5639
diff
changeset
|
332 |
{ 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED } |
0 | 333 |
}; |
334 |
||
335 |
static void BuildTreesWndProc(Window *w, WindowEvent *e) |
|
336 |
{ |
|
2639 | 337 |
switch (e->event) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
338 |
case WE_PAINT: { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
339 |
int i, count; |
0 | 340 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
341 |
DrawWindowWidgets(w); |
0 | 342 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
343 |
WP(w, tree_d).base = i = _tree_base_by_landscape[_opt.landscape]; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
344 |
WP(w, tree_d).count = count = _tree_count_by_landscape[_opt.landscape]; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
345 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
346 |
int x = 18; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
347 |
int y = 54; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
348 |
do { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
349 |
DrawSprite(_tree_sprites[i].sprite, _tree_sprites[i].pal, x, y); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
350 |
x += 35; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
351 |
if (!(++i & 3)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
352 |
x -= 35 * 4; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
353 |
y += 47; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
354 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
355 |
} while (--count); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
356 |
} break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
357 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
358 |
case WE_CLICK: { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
359 |
int wid = e->we.click.widget; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
360 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
361 |
switch (wid) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
362 |
case 0: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
363 |
ResetObjectToPlace(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
364 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
365 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
366 |
case 3: case 4: case 5: case 6: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
367 |
case 7: case 8: case 9: case 10: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
368 |
case 11:case 12: case 13: case 14: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
369 |
if (wid - 3 >= WP(w, tree_d).count) break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
370 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
371 |
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
372 |
_tree_to_plant = WP(w, tree_d).base + wid - 3; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
373 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
374 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
375 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
376 |
case 15: // tree of random type. |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
377 |
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
378 |
_tree_to_plant = -1; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
379 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
380 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
381 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
382 |
case 16: // place trees randomly over the landscape |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
383 |
w->LowerWidget(16); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
384 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
385 |
SndPlayFx(SND_15_BEEP); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
386 |
PlaceTreesRandomly(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
387 |
MarkWholeScreenDirty(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
388 |
break; |
0 | 389 |
} |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
390 |
} break; |
0 | 391 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
392 |
case WE_PLACE_OBJ: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
393 |
VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED, DDSP_PLANT_TREES); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
394 |
VpSetPlaceSizingLimit(20); |
0 | 395 |
break; |
396 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
397 |
case WE_PLACE_DRAG: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
398 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
399 |
return; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
400 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
401 |
case WE_PLACE_MOUSEUP: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
402 |
if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_PLANT_TREES) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
403 |
DoCommandP(e->we.place.tile, _tree_to_plant, e->we.place.starttile, NULL, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
404 |
CMD_PLANT_TREE | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
405 |
} |
0 | 406 |
break; |
407 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
408 |
case WE_TIMEOUT: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
409 |
w->RaiseWidget(16); |
0 | 410 |
break; |
411 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
412 |
case WE_ABORT_PLACE_OBJ: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
413 |
w->RaiseButtons(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
414 |
break; |
0 | 415 |
} |
416 |
} |
|
417 |
||
418 |
static const Widget _build_trees_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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, 7, 0, 142, 14, 170, 0x0, STR_NULL}, |
7e123fec5b0b
(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, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 72, 105, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 107, 140, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 2, 35, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 37, 70, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 14, 72, 105, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
429 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
430 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
431 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
432 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
433 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
434 |
{ 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
|
435 |
{ WIDGETS_END}, |
0 | 436 |
}; |
437 |
||
438 |
static const WindowDesc _build_trees_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
439 |
497, 22, 143, 171, 143, 171, |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
598
diff
changeset
|
440 |
WC_BUILD_TREES, WC_SCEN_LAND_GEN, |
0 | 441 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
442 |
_build_trees_widgets, |
|
443 |
BuildTreesWndProc |
|
444 |
}; |
|
445 |
||
446 |
static const Widget _build_trees_scen_widgets[] = { |
|
4344
7e123fec5b0b
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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, 7, 0, 142, 14, 183, 0x0, STR_NULL}, |
7e123fec5b0b
(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, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 72, 105, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 107, 140, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 2, 35, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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, 37, 70, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 14, 72, 105, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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_PANEL, RESIZE_NONE, 14, 107, 140, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
458 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 35, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
459 |
{ WWT_PANEL, RESIZE_NONE, 14, 37, 70, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
460 |
{ WWT_PANEL, RESIZE_NONE, 14, 72, 105, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
461 |
{ WWT_PANEL, RESIZE_NONE, 14, 107, 140, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
7e123fec5b0b
(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
|
462 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 140, 157, 168, STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TIP}, |
7e123fec5b0b
(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
|
463 |
{ 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
|
464 |
{ WIDGETS_END}, |
0 | 465 |
}; |
466 |
||
467 |
static const WindowDesc _build_trees_scen_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
468 |
WDP_AUTO, WDP_AUTO, 143, 184, 143, 184, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
469 |
WC_BUILD_TREES, WC_NONE, |
0 | 470 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
471 |
_build_trees_scen_widgets, |
|
472 |
BuildTreesWndProc |
|
473 |
}; |
|
474 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
475 |
|
6247 | 476 |
void ShowBuildTreesToolbar() |
0 | 477 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
478 |
if (!IsValidPlayer(_current_player)) return; |
1846
7fcf64b5ba45
(svn r2351) -Fix: It was possible to open more than one tree window
tron
parents:
1843
diff
changeset
|
479 |
AllocateWindowDescFront(&_build_trees_desc, 0); |
0 | 480 |
} |
481 |
||
6247 | 482 |
void ShowBuildTreesScenToolbar() |
0 | 483 |
{ |
484 |
AllocateWindowDescFront(&_build_trees_scen_desc, 0); |
|
485 |
} |
|
486 |
||
7002
1bf6a62b0fcb
(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:
6998
diff
changeset
|
487 |
static uint64 _errmsg_decode_params[20]; |
0 | 488 |
static StringID _errmsg_message_1, _errmsg_message_2; |
489 |
static uint _errmsg_duration; |
|
490 |
||
491 |
||
492 |
static const Widget _errmsg_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
493 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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_CAPTION, RESIZE_NONE, 4, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL}, |
7e123fec5b0b
(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_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
|
496 |
{ WIDGETS_END}, |
0 | 497 |
}; |
498 |
||
499 |
static const Widget _errmsg_face_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
500 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
501 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL}, |
7e123fec5b0b
(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
|
502 |
{ 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
|
503 |
{ WIDGETS_END}, |
0 | 504 |
}; |
505 |
||
506 |
static void ErrmsgWndProc(Window *w, WindowEvent *e) |
|
507 |
{ |
|
2639 | 508 |
switch (e->event) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
509 |
case WE_PAINT: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
510 |
CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
511 |
DrawWindowWidgets(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
512 |
CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
7750
7afbef1235e0
(svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents:
7521
diff
changeset
|
513 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
514 |
/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages. |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
515 |
* If the message doesn't come from a NewGRF, it won't use the TTDP-style text ref. stack, so we won't hurt anything |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
516 |
*/ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
517 |
SwitchToErrorRefStack(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
518 |
RewindTextRefStack(); |
7750
7afbef1235e0
(svn r11287) -Codechange: add support for pushing paramaters into NewIndustries' error messages. Patch by Csaboka.
rubidium
parents:
7521
diff
changeset
|
519 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
520 |
if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { |
0 | 521 |
DrawStringMultiCenter( |
522 |
120, |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
523 |
(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15), |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
524 |
_errmsg_message_2, |
6197
558f3a9b5bd4
(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:
6190
diff
changeset
|
525 |
w->width - 2); |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
526 |
if (_errmsg_message_1 != INVALID_STRING_ID) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
527 |
DrawStringMultiCenter( |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
528 |
120, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
529 |
30, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
530 |
_errmsg_message_1, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
531 |
w->width - 2); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
532 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
533 |
} else { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
534 |
const Player *p = GetPlayer((PlayerID)GetDParamX(_errmsg_decode_params,2)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
535 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
0 | 536 |
|
537 |
DrawStringMultiCenter( |
|
538 |
214, |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
539 |
(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45), |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
540 |
_errmsg_message_2, |
6197
558f3a9b5bd4
(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:
6190
diff
changeset
|
541 |
w->width - 2); |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
542 |
if (_errmsg_message_1 != INVALID_STRING_ID) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
543 |
DrawStringMultiCenter( |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
544 |
214, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
545 |
90, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
546 |
_errmsg_message_1, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
547 |
w->width - 2); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
548 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
549 |
} |
2639 | 550 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
551 |
/* Switch back to the normal text ref. stack for NewGRF texts */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
552 |
SwitchToNormalRefStack(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
553 |
break; |
2639 | 554 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
555 |
case WE_MOUSELOOP: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
556 |
if (_right_button_down) DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
557 |
break; |
0 | 558 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
559 |
case WE_4: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
560 |
if (--_errmsg_duration == 0) DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
561 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
562 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
563 |
case WE_DESTROY: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
564 |
SetRedErrorSquare(0); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
565 |
_switch_mode_errorstr = INVALID_STRING_ID; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
566 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
567 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
568 |
case WE_KEYPRESS: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
569 |
if (e->we.keypress.keycode == WKC_SPACE) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
570 |
/* Don't continue. */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
571 |
e->we.keypress.cont = false; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
572 |
DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
573 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
574 |
break; |
0 | 575 |
} |
576 |
} |
|
577 |
||
578 |
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) |
|
579 |
{ |
|
580 |
Window *w; |
|
5120
1ff65e874ce3
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
581 |
const ViewPort *vp; |
0 | 582 |
Point pt; |
583 |
||
584 |
DeleteWindowById(WC_ERRMSG, 0); |
|
585 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
586 |
if (msg_2 == STR_NULL) msg_2 = STR_EMPTY; |
0 | 587 |
|
588 |
_errmsg_message_1 = msg_1; |
|
589 |
_errmsg_message_2 = msg_2; |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7241
diff
changeset
|
590 |
CopyOutDParam(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); |
0 | 591 |
_errmsg_duration = _patches.errmsg_duration; |
5120
1ff65e874ce3
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
592 |
if (!_errmsg_duration) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
593 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
594 |
if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
595 |
if ((x | y) != 0) { |
0 | 596 |
pt = RemapCoords2(x, y); |
5120
1ff65e874ce3
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
597 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
0 | 598 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
599 |
/* move x pos to opposite corner */ |
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6492
diff
changeset
|
600 |
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left; |
0 | 601 |
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
|
602 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
603 |
/* move y pos to opposite corner */ |
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6492
diff
changeset
|
604 |
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; |
0 | 605 |
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
|
606 |
|
0 | 607 |
} else { |
608 |
pt.x = (_screen.width - 240) >> 1; |
|
609 |
pt.y = (_screen.height - 46) >> 1; |
|
610 |
} |
|
611 |
w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
|
612 |
} else { |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
613 |
if ((x | y) != 0) { |
0 | 614 |
pt = RemapCoords2(x, y); |
5120
1ff65e874ce3
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
615 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
7922
a7e266f966d9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
7889
diff
changeset
|
616 |
pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
a7e266f966d9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
7889
diff
changeset
|
617 |
pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
0 | 618 |
} else { |
619 |
pt.x = (_screen.width - 334) >> 1; |
|
620 |
pt.y = (_screen.height - 137) >> 1; |
|
621 |
} |
|
622 |
w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
|
623 |
} |
|
624 |
||
625 |
w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
|
626 |
} |
|
627 |
||
628 |
||
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6953
diff
changeset
|
629 |
void ShowEstimatedCostOrIncome(Money cost, int x, int y) |
0 | 630 |
{ |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
631 |
StringID msg = STR_0805_ESTIMATED_COST; |
0 | 632 |
|
633 |
if (cost < 0) { |
|
634 |
cost = -cost; |
|
635 |
msg = STR_0807_ESTIMATED_INCOME; |
|
636 |
} |
|
7002
1bf6a62b0fcb
(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:
6998
diff
changeset
|
637 |
SetDParam(0, cost); |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
638 |
ShowErrorMessage(INVALID_STRING_ID, msg, x, y); |
0 | 639 |
} |
640 |
||
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6953
diff
changeset
|
641 |
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost) |
0 | 642 |
{ |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
643 |
StringID msg; |
0 | 644 |
Point pt = RemapCoords(x,y,z); |
645 |
||
646 |
msg = STR_0801_COST; |
|
647 |
if (cost < 0) { |
|
648 |
cost = -cost; |
|
649 |
msg = STR_0803_INCOME; |
|
650 |
} |
|
7002
1bf6a62b0fcb
(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:
6998
diff
changeset
|
651 |
SetDParam(0, cost); |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
652 |
AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING); |
0 | 653 |
} |
654 |
||
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6953
diff
changeset
|
655 |
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost) |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
656 |
{ |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
657 |
Point pt = RemapCoords(x,y,z); |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
658 |
|
7002
1bf6a62b0fcb
(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:
6998
diff
changeset
|
659 |
SetDParam(0, cost); |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
660 |
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING); |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
661 |
} |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
662 |
|
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
663 |
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string) |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
664 |
{ |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
665 |
Point pt = RemapCoords(x, y, z); |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
666 |
|
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
667 |
assert(string != STR_NULL); |
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
668 |
|
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
669 |
SetDParam(0, percent); |
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
670 |
return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC); |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
671 |
} |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
672 |
|
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
673 |
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string) |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
674 |
{ |
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
675 |
assert(string != STR_NULL); |
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
676 |
|
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
677 |
SetDParam(0, percent); |
7014
533521754123
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents:
7007
diff
changeset
|
678 |
UpdateTextEffect(te_id, string); |
6998
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
679 |
} |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
680 |
|
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
681 |
void HideFillingPercent(TextEffectID te_id) |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
682 |
{ |
39e783d3816c
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
6991
diff
changeset
|
683 |
if (te_id != INVALID_TE_ID) RemoveTextEffect(te_id); |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
684 |
} |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
685 |
|
2275
11a1dac70c45
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
686 |
static const Widget _tooltips_widgets[] = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
687 |
{ 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
|
688 |
{ WIDGETS_END}, |
0 | 689 |
}; |
690 |
||
691 |
||
692 |
static void TooltipsWndProc(Window *w, WindowEvent *e) |
|
693 |
{ |
|
2639 | 694 |
switch (e->event) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
695 |
case WE_PAINT: |
2639 | 696 |
GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
697 |
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
|
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
698 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
699 |
for (uint arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) { |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
700 |
SetDParam(arg, WP(w, tooltips_d).params[arg]); |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
701 |
} |
6197
558f3a9b5bd4
(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:
6190
diff
changeset
|
702 |
DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w, tooltips_d).string_id, w->width - 2); |
2639 | 703 |
break; |
0 | 704 |
|
2639 | 705 |
case WE_MOUSELOOP: |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
706 |
/* We can show tooltips while dragging tools. These are shown as long as |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
707 |
* we are dragging the tool. Normal tooltips work with rmb */ |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
708 |
if (WP(w, tooltips_d).paramcount == 0 ) { |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
709 |
if (!_right_button_down) DeleteWindow(w); |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
710 |
} else { |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
711 |
if (!_left_button_down) DeleteWindow(w); |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
712 |
} |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
713 |
|
2639 | 714 |
break; |
0 | 715 |
} |
716 |
} |
|
717 |
||
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
718 |
/** Shows a tooltip |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
719 |
* @param str String to be displayed |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
720 |
* @param paramcount number of params to deal with |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
721 |
* @param params (optional) up to 5 pieces of additional information that may be |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
722 |
* added to a tooltip; currently only supports parameters of {NUM} (integer) */ |
7006
bfa3974da32b
(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:
7002
diff
changeset
|
723 |
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]) |
0 | 724 |
{ |
4884
94dd5df0d584
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
725 |
DeleteWindowById(WC_TOOLTIPS, 0); |
0 | 726 |
|
4884
94dd5df0d584
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
727 |
/* We only show measurement tooltips with patch setting on */ |
94dd5df0d584
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
728 |
if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return; |
0 | 729 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
730 |
for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
731 |
char buffer[512]; |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
732 |
GetString(buffer, str, lastof(buffer)); |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
733 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
734 |
Dimension br = GetStringBoundingBox(buffer); |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
735 |
br.width += 6; br.height += 4; // increase slightly to have some space around the box |
0 | 736 |
|
4558
0c21ecb2b34e
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
737 |
/* Cut tooltip length to 200 pixels max, wrap to new line if longer */ |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
738 |
if (br.width > 200) { |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
739 |
br.height += ((br.width - 4) / 176) * 10; |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
740 |
br.width = 200; |
0 | 741 |
} |
742 |
||
4558
0c21ecb2b34e
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
743 |
/* Correctly position the tooltip position, watch out for window and cursor size |
0c21ecb2b34e
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
744 |
* Clamp value to below main toolbar and above statusbar. If tooltip would |
0c21ecb2b34e
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
745 |
* go below window, flip it so it is shown above the cursor */ |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
746 |
int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
747 |
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
748 |
int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); |
0 | 749 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
750 |
Window *w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
751 |
|
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
752 |
WP(w, tooltips_d).string_id = str; |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
753 |
assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0])); |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
754 |
memcpy(WP(w, tooltips_d).params, params, sizeof(WP(w, tooltips_d).params[0]) * paramcount); |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
755 |
WP(w, tooltips_d).paramcount = paramcount; |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
756 |
|
4558
0c21ecb2b34e
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
757 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip |
4834
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
758 |
w->widget[0].right = br.width; |
3c6e8a547174
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
759 |
w->widget[0].bottom = br.height; |
0 | 760 |
} |
761 |
||
762 |
||
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
763 |
static int DrawStationCoverageText(const AcceptedCargo accepts, |
7241
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
764 |
int str_x, int str_y, StationCoverageType sct) |
0 | 765 |
{ |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
766 |
char *b = _userstring; |
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
767 |
bool first = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
768 |
|
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1500
diff
changeset
|
769 |
b = InlineString(b, STR_000D_ACCEPTS); |
0 | 770 |
|
7241
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
771 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
8041
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8036
diff
changeset
|
772 |
if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
7241
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
773 |
switch (sct) { |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
774 |
case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
775 |
case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
776 |
case SCT_ALL: break; |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
777 |
default: NOT_REACHED(); |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
778 |
} |
7fd23b6f6713
(svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents:
7138
diff
changeset
|
779 |
if (accepts[i] >= 8) { |
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
780 |
if (first) { |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
781 |
first = false; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
782 |
} else { |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
783 |
/* Add a comma if this is not the first item */ |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
784 |
*b++ = ','; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
785 |
*b++ = ' '; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
786 |
} |
6091
c8827d9ae04a
(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:
5893
diff
changeset
|
787 |
b = InlineString(b, GetCargo(i)->name); |
0 | 788 |
} |
789 |
} |
|
790 |
||
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
791 |
/* If first is still true then no cargo is accepted */ |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
792 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
0 | 793 |
|
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
794 |
*b = '\0'; |
8041
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8036
diff
changeset
|
795 |
|
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8036
diff
changeset
|
796 |
/* Make sure we detect any buffer overflow */ |
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8036
diff
changeset
|
797 |
assert(b < endof(_userstring)); |
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8036
diff
changeset
|
798 |
|
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
799 |
return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
0 | 800 |
} |
801 |
||
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
802 |
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) |
7321
f91bdca345e8
(svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents:
7266
diff
changeset
|
803 |
{ |
2873 | 804 |
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
805 |
AcceptedCargo accepts; |
2873 | 806 |
if (tile < MapSize()) { |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3329
diff
changeset
|
807 |
GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
808 |
return sy + DrawStationCoverageText(accepts, sx, sy, sct); |
0 | 809 |
} |
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
810 |
|
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8349
diff
changeset
|
811 |
return sy; |
0 | 812 |
} |
813 |
||
4171 | 814 |
void CheckRedrawStationCoverage(const Window *w) |
0 | 815 |
{ |
2549 | 816 |
if (_thd.dirty & 1) { |
817 |
_thd.dirty &= ~1; |
|
0 | 818 |
SetWindowDirty(w); |
819 |
} |
|
820 |
} |
|
821 |
||
822 |
void SetVScrollCount(Window *w, int num) |
|
823 |
{ |
|
824 |
w->vscroll.count = num; |
|
825 |
num -= w->vscroll.cap; |
|
826 |
if (num < 0) num = 0; |
|
827 |
if (num < w->vscroll.pos) w->vscroll.pos = num; |
|
828 |
} |
|
829 |
||
842 | 830 |
void SetVScroll2Count(Window *w, int num) |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
831 |
{ |
842 | 832 |
w->vscroll2.count = num; |
833 |
num -= w->vscroll2.cap; |
|
834 |
if (num < 0) num = 0; |
|
835 |
if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
|
836 |
} |
|
837 |
||
0 | 838 |
void SetHScrollCount(Window *w, int num) |
839 |
{ |
|
840 |
w->hscroll.count = num; |
|
841 |
num -= w->hscroll.cap; |
|
842 |
if (num < 0) num = 0; |
|
843 |
if (num < w->hscroll.pos) w->hscroll.pos = num; |
|
844 |
} |
|
845 |
||
5108
aeaef6fe53b7
(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
|
846 |
/* Delete a character at the caret position in a text buf. |
aeaef6fe53b7
(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
|
847 |
* If backspace is set, delete the character before the caret, |
aeaef6fe53b7
(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
|
848 |
* else delete the character after it. */ |
aeaef6fe53b7
(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
|
849 |
static void DelChar(Textbuf *tb, bool backspace) |
911
7ccc33888a33
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
850 |
{ |
5108
aeaef6fe53b7
(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
|
851 |
WChar c; |
6214
1f361897ed7f
(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:
6211
diff
changeset
|
852 |
char *s = tb->buf + tb->caretpos; |
5108
aeaef6fe53b7
(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
|
853 |
|
6214
1f361897ed7f
(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:
6211
diff
changeset
|
854 |
if (backspace) s = Utf8PrevChar(s); |
5108
aeaef6fe53b7
(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
|
855 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
856 |
size_t len = Utf8Decode(&c, s); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
857 |
uint width = GetCharacterWidth(FS_NORMAL, c); |
5108
aeaef6fe53b7
(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
|
858 |
|
aeaef6fe53b7
(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 |
tb->width -= width; |
6214
1f361897ed7f
(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:
6211
diff
changeset
|
860 |
if (backspace) { |
1f361897ed7f
(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:
6211
diff
changeset
|
861 |
tb->caretpos -= len; |
1f361897ed7f
(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:
6211
diff
changeset
|
862 |
tb->caretxoffs -= width; |
1f361897ed7f
(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:
6211
diff
changeset
|
863 |
} |
5108
aeaef6fe53b7
(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
|
864 |
|
aeaef6fe53b7
(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
|
865 |
/* Move the remaining characters over the marker */ |
6214
1f361897ed7f
(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:
6211
diff
changeset
|
866 |
memmove(s, s + len, tb->length - (s - tb->buf) - len + 1); |
5108
aeaef6fe53b7
(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
|
867 |
tb->length -= len; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
868 |
} |
911
7ccc33888a33
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
869 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
870 |
/** |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
871 |
* Delete a character from a textbuffer, either with 'Delete' or 'Backspace' |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
872 |
* The character is delete from the position the caret is at |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
873 |
* @param tb Textbuf type to be changed |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
874 |
* @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE |
7372
6fac48ff7c4d
(svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents:
7346
diff
changeset
|
875 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
876 |
*/ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
877 |
bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
878 |
{ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
879 |
if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
5108
aeaef6fe53b7
(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
|
880 |
DelChar(tb, true); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
881 |
return true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
882 |
} else if (delmode == WKC_DELETE && tb->caretpos < tb->length) { |
5108
aeaef6fe53b7
(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
|
883 |
DelChar(tb, false); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
884 |
return true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
885 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
886 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
887 |
return false; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
888 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
889 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
890 |
/** |
1879
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
891 |
* Delete every character in the textbuffer |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
892 |
* @param tb Textbuf buffer to be emptied |
1879
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
893 |
*/ |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
894 |
void DeleteTextBufferAll(Textbuf *tb) |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
895 |
{ |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
896 |
memset(tb->buf, 0, tb->maxlength); |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
897 |
tb->length = tb->width = 0; |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
898 |
tb->caretpos = tb->caretxoffs = 0; |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
899 |
} |
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
900 |
|
b037d07154c6
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
901 |
/** |
3459
c6096d4423aa
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
902 |
* Insert a character to a textbuffer. If maxwidth of the Textbuf is zero, |
c6096d4423aa
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
903 |
* we don't care about the visual-length but only about the physical |
3458
26360c9a3743
(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
|
904 |
* length of the string |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
905 |
* @param tb Textbuf type to be changed |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
906 |
* @param key Character to be inserted |
7372
6fac48ff7c4d
(svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents:
7346
diff
changeset
|
907 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
908 |
*/ |
5108
aeaef6fe53b7
(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
|
909 |
bool InsertTextBufferChar(Textbuf *tb, WChar key) |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
910 |
{ |
3798
b1f5290b36b1
(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
|
911 |
const byte charwidth = GetCharacterWidth(FS_NORMAL, key); |
5108
aeaef6fe53b7
(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
|
912 |
size_t len = Utf8CharLen(key); |
aeaef6fe53b7
(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
|
913 |
if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
aeaef6fe53b7
(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 |
memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); |
aeaef6fe53b7
(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
|
915 |
Utf8Encode(tb->buf + tb->caretpos, key); |
aeaef6fe53b7
(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
|
916 |
tb->length += len; |
aeaef6fe53b7
(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
|
917 |
tb->width += charwidth; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
918 |
|
5108
aeaef6fe53b7
(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 |
tb->caretpos += len; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
920 |
tb->caretxoffs += charwidth; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
921 |
return true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
922 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
923 |
return false; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
924 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
925 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
926 |
/** |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
927 |
* Handle text navigation with arrow keys left/right. |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
928 |
* This defines where the caret will blink and the next characer interaction will occur |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
929 |
* @param tb Textbuf type where navigation occurs |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
930 |
* @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME |
7372
6fac48ff7c4d
(svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents:
7346
diff
changeset
|
931 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
932 |
*/ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
933 |
bool MoveTextBufferPos(Textbuf *tb, int navmode) |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
934 |
{ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
935 |
switch (navmode) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
936 |
case WKC_LEFT: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
937 |
if (tb->caretpos != 0) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
938 |
WChar c; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
939 |
const char *s = Utf8PrevChar(tb->buf + tb->caretpos); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
940 |
Utf8Decode(&c, s); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
941 |
tb->caretpos = s - tb->buf; // -= (tb->buf + tb->caretpos - s) |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
942 |
tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c); |
5108
aeaef6fe53b7
(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
|
943 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
944 |
return true; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
945 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
946 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
947 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
948 |
case WKC_RIGHT: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
949 |
if (tb->caretpos < tb->length) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
950 |
WChar c; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
951 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
952 |
tb->caretpos += Utf8Decode(&c, tb->buf + tb->caretpos); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
953 |
tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
954 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
955 |
return true; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
956 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
957 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
958 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
959 |
case WKC_HOME: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
960 |
tb->caretpos = 0; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
961 |
tb->caretxoffs = 0; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
962 |
return true; |
5108
aeaef6fe53b7
(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
|
963 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
964 |
case WKC_END: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
965 |
tb->caretpos = tb->length; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
966 |
tb->caretxoffs = tb->width; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
967 |
return true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
968 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
969 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
970 |
return false; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
971 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
972 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
973 |
/** |
4948
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
974 |
* Initialize the textbuffer by supplying it the buffer to write into |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
975 |
* and the maximum length of this buffer |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
976 |
* @param tb Textbuf type which is getting initialized |
4948
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
977 |
* @param buf the buffer that will be holding the data for input |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
978 |
* @param maxlength maximum length in characters of this buffer |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
979 |
* @param maxwidth maximum length in pixels of this buffer. If reached, buffer |
4958 | 980 |
* cannot grow, even if maxlength would allow because there is space. A length |
981 |
* of zero '0' means the buffer is only restricted by maxlength */ |
|
4948
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
982 |
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth) |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
983 |
{ |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
984 |
tb->buf = (char*)buf; |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
985 |
tb->maxlength = maxlength; |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
986 |
tb->maxwidth = maxwidth; |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
987 |
tb->caret = true; |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
988 |
UpdateTextBufferSize(tb); |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
989 |
} |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
990 |
|
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
991 |
/** |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
992 |
* Update Textbuf type with its actual physical character and screenlength |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
993 |
* Get the count of characters in the string as well as the width in pixels. |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
994 |
* Useful when copying in a larger amount of text at once |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
995 |
* @param tb Textbuf type which length is calculated |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
996 |
*/ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
997 |
void UpdateTextBufferSize(Textbuf *tb) |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
998 |
{ |
5108
aeaef6fe53b7
(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
|
999 |
const char *buf = tb->buf; |
aeaef6fe53b7
(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
|
1000 |
WChar c = Utf8Consume(&buf); |
2630 | 1001 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1002 |
tb->width = 0; |
5447
4bdf874190e8
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5431
diff
changeset
|
1003 |
tb->length = 0; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1004 |
|
5108
aeaef6fe53b7
(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
|
1005 |
for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) { |
aeaef6fe53b7
(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
|
1006 |
tb->width += GetCharacterWidth(FS_NORMAL, c); |
5447
4bdf874190e8
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5431
diff
changeset
|
1007 |
tb->length += Utf8CharLen(c); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1008 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1009 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1010 |
tb->caretpos = tb->length; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1011 |
tb->caretxoffs = tb->width; |
911
7ccc33888a33
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
1012 |
} |
7ccc33888a33
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
1013 |
|
4909
955f318a24cd
(svn r6879) -Codechange: Remove the superflouos argument CharsetFilter parameter from HandleEditBoxKey
Darkvater
parents:
4884
diff
changeset
|
1014 |
int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e) |
0 | 1015 |
{ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1016 |
e->we.keypress.cont = false; |
0 | 1017 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1018 |
switch (e->we.keypress.keycode) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1019 |
case WKC_ESC: return 2; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1020 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1021 |
case WKC_RETURN: case WKC_NUM_ENTER: return 1; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1022 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1023 |
case (WKC_CTRL | 'V'): |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1024 |
if (InsertTextBufferClipboard(&string->text)) w->InvalidateWidget(wid); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1025 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1026 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1027 |
case (WKC_CTRL | 'U'): |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1028 |
DeleteTextBufferAll(&string->text); |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
8019
diff
changeset
|
1029 |
w->InvalidateWidget(wid); |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1030 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1031 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1032 |
case WKC_BACKSPACE: case WKC_DELETE: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1033 |
if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1034 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1035 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1036 |
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1037 |
if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1038 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1039 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1040 |
default: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1041 |
if (IsValidChar(e->we.keypress.key, string->afilter)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1042 |
if (InsertTextBufferChar(&string->text, e->we.keypress.key)) w->InvalidateWidget(wid); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1043 |
} else { // key wasn't caught. Continue only if standard entry specified |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1044 |
e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL); |
5108
aeaef6fe53b7
(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
|
1045 |
} |
0 | 1046 |
} |
1047 |
||
1048 |
return 0; |
|
1049 |
} |
|
1050 |
||
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1051 |
bool HandleCaret(Textbuf *tb) |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1052 |
{ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1053 |
/* caret changed? */ |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1054 |
bool b = !!(_caret_timer & 0x20); |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1055 |
|
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1056 |
if (b != tb->caret) { |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1057 |
tb->caret = b; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1058 |
return true; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1059 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1060 |
return false; |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1061 |
} |
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1062 |
|
2887
810e555d5249
(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
|
1063 |
void HandleEditBox(Window *w, querystr_d *string, int wid) |
0 | 1064 |
{ |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
8019
diff
changeset
|
1065 |
if (HandleCaret(&string->text)) w->InvalidateWidget(wid); |
0 | 1066 |
} |
1067 |
||
2887
810e555d5249
(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
|
1068 |
void DrawEditBox(Window *w, querystr_d *string, int wid) |
0 | 1069 |
{ |
4955
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1070 |
DrawPixelInfo dpi, *old_dpi; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1071 |
int delta; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1072 |
const Widget *wi = &w->widget[wid]; |
2887
810e555d5249
(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
|
1073 |
const Textbuf *tb = &string->text; |
0 | 1074 |
|
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1075 |
assert((wi->type & WWT_MASK) == WWT_EDITBOX); |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1076 |
|
5639
c9c55071b0ea
(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:
5596
diff
changeset
|
1077 |
GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215); |
c9c55071b0ea
(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:
5596
diff
changeset
|
1078 |
|
4955
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1079 |
/* Limit the drawing of the string inside the widget boundaries */ |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1080 |
if (!FillDrawPixelInfo(&dpi, |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1081 |
wi->left + 4, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1082 |
wi->top + 1, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1083 |
wi->right - wi->left - 4, |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1084 |
wi->bottom - wi->top - 1)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1085 |
return; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1086 |
} |
4955
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1087 |
|
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1088 |
old_dpi = _cur_dpi; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1089 |
_cur_dpi = &dpi; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1090 |
|
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1091 |
/* We will take the current widget length as maximum width, with a small |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1092 |
* space reserved at the end for the caret to show */ |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1093 |
delta = (wi->right - wi->left) - tb->width - 10; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1094 |
if (delta > 0) delta = 0; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1095 |
|
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1096 |
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs; |
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1097 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1098 |
DoDrawString(tb->buf, delta, 0, TC_YELLOW); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1099 |
if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE); |
4955
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1100 |
|
1ffc9ce449a8
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
1101 |
_cur_dpi = old_dpi; |
0 | 1102 |
} |
1103 |
||
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1104 |
enum QueryStringWidgets { |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1105 |
QUERY_STR_WIDGET_TEXT = 3, |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1106 |
QUERY_STR_WIDGET_CANCEL, |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1107 |
QUERY_STR_WIDGET_OK |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1108 |
}; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1109 |
|
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1110 |
|
0 | 1111 |
static void QueryStringWndProc(Window *w, WindowEvent *e) |
1112 |
{ |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1113 |
querystr_d *qs = &WP(w, querystr_d); |
0 | 1114 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1115 |
switch (e->event) { |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1116 |
case WE_CREATE: |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
1117 |
SetBit(_no_scroll, SCROLL_EDIT); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1118 |
break; |
390
c67581486cde
(svn r582) -Fix: [ 1034318 ] place sign and blue message box
tron
parents:
337
diff
changeset
|
1119 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1120 |
case WE_PAINT: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1121 |
SetDParam(0, qs->caption); |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1122 |
DrawWindowWidgets(w); |
598
b8c5ae66f9ff
(svn r1022) -Fix: [Network] [ 1083690 ] The password dialog made the network
truelight
parents:
596
diff
changeset
|
1123 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1124 |
DrawEditBox(w, qs, QUERY_STR_WIDGET_TEXT); |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1125 |
break; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1126 |
|
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1127 |
case WE_CLICK: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1128 |
switch (e->we.click.widget) { |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1129 |
case QUERY_STR_WIDGET_TEXT: |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1130 |
ShowOnScreenKeyboard(w, &WP(w, querystr_d), QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK); |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1131 |
break; |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1132 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1133 |
case QUERY_STR_WIDGET_OK: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1134 |
press_ok:; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1135 |
if (qs->orig == NULL || strcmp(qs->text.buf, qs->orig) != 0) { |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1136 |
Window *parent = w->parent; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1137 |
qs->handled = true; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1138 |
|
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1139 |
/* If the parent is NULL, the editbox is handled by general function |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1140 |
* HandleOnEditText */ |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1141 |
if (parent != NULL) { |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1142 |
WindowEvent e; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1143 |
e.event = WE_ON_EDIT_TEXT; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1144 |
e.we.edittext.str = qs->text.buf; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1145 |
parent->wndproc(parent, &e); |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1146 |
} else { |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1147 |
HandleOnEditText(qs->text.buf); |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1148 |
} |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1149 |
} |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1150 |
/* Fallthrough */ |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1151 |
case QUERY_STR_WIDGET_CANCEL: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1152 |
DeleteWindow(w); |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1153 |
break; |
0 | 1154 |
} |
1155 |
break; |
|
1156 |
||
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1157 |
case WE_MOUSELOOP: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1158 |
HandleEditBox(w, qs, QUERY_STR_WIDGET_TEXT); |
0 | 1159 |
break; |
1160 |
||
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1161 |
case WE_KEYPRESS: |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1162 |
switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1163 |
case 1: goto press_ok; // Enter pressed, confirms change |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1164 |
case 2: DeleteWindow(w); break; // ESC pressed, closes window, abandons changes |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1165 |
} |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1166 |
break; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1167 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1168 |
case WE_DESTROY: // Call cancellation of query, if we have not handled it before |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1169 |
if (!qs->handled && w->parent != NULL) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1170 |
WindowEvent e; |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1171 |
Window *parent = w->parent; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1172 |
|
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1173 |
qs->handled = true; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1174 |
e.event = WE_ON_EDIT_TEXT_CANCEL; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1175 |
parent->wndproc(parent, &e); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1176 |
} |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
1177 |
ClrBit(_no_scroll, SCROLL_EDIT); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1178 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1179 |
} |
0 | 1180 |
} |
1181 |
||
1182 |
static const Widget _query_string_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
1183 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
1184 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1185 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1186 |
{ WWT_EDITBOX, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(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
|
1187 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, |
7e123fec5b0b
(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
|
1188 |
{ 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
|
1189 |
{ WIDGETS_END}, |
0 | 1190 |
}; |
1191 |
||
1192 |
static const WindowDesc _query_string_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
1193 |
190, 219, 260, 42, 260, 42, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
1194 |
WC_QUERY_STRING, WC_NONE, |
8019
fc0e94dee165
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8018
diff
changeset
|
1195 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
0 | 1196 |
_query_string_widgets, |
1197 |
QueryStringWndProc |
|
1198 |
}; |
|
1199 |
||
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1200 |
char _edit_str_buf[64]; |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1201 |
char _orig_str_buf[lengthof(_edit_str_buf)]; |
0 | 1202 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1203 |
/** Show a query popup window with a textbox in it. |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1204 |
* @param str StringID for the text shown in the textbox |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1205 |
* @param caption StringID of text shown in caption of querywindow |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1206 |
* @param maxlen maximum length in characters allowed. If bit 12 is set we |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1207 |
* will not check the resulting string against to original string to return success |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1208 |
* @param maxwidth maximum width in pixels allowed |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1209 |
* @param parent pointer to a Window that will handle the events (ok/cancel) of this |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1210 |
* window. If NULL, results are handled by global function HandleOnEditText |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1211 |
* @param afilter filters out unwanted character input */ |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1212 |
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter) |
0 | 1213 |
{ |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1214 |
uint realmaxlen = maxlen & ~0x1000; |
0 | 1215 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1216 |
assert(realmaxlen < lengthof(_edit_str_buf)); |
0 | 1217 |
|
1218 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1219 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1220 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1221 |
Window *w = AllocateWindowDesc(&_query_string_desc); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5429
diff
changeset
|
1222 |
w->parent = parent; |
1386
0de4f8541aea
(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
|
1223 |
|
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1224 |
GetString(_edit_str_buf, str, lastof(_edit_str_buf)); |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4948
diff
changeset
|
1225 |
_edit_str_buf[realmaxlen - 1] = '\0'; |
596
a787fc8fba4a
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1226 |
|
a787fc8fba4a
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1227 |
if (maxlen & 0x1000) { |
1386
0de4f8541aea
(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
|
1228 |
WP(w, querystr_d).orig = NULL; |
0de4f8541aea
(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
|
1229 |
} else { |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1230 |
strecpy(_orig_str_buf, _edit_str_buf, lastof(_orig_str_buf)); |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1231 |
WP(w, querystr_d).orig = _orig_str_buf; |
1386
0de4f8541aea
(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
|
1232 |
} |
0 | 1233 |
|
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
1234 |
w->LowerWidget(QUERY_STR_WIDGET_TEXT); |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1235 |
WP(w, querystr_d).caption = caption; |
4299
91f5d2bedcff
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
1236 |
WP(w, querystr_d).afilter = afilter; |
4948
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1237 |
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, realmaxlen, maxwidth); |
0 | 1238 |
} |
1239 |
||
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1240 |
|
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1241 |
enum QueryWidgets { |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1242 |
QUERY_WIDGET_CAPTION = 1, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1243 |
QUERY_WIDGET_NO = 3, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1244 |
QUERY_WIDGET_YES |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1245 |
}; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1246 |
|
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1247 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
1248 |
struct query_d { |
5473
6dc579e62412
(svn r7757) -Fix (r7621): x64 did not compile because query_d was too big. Reorder the elements
Darkvater
parents:
5469
diff
changeset
|
1249 |
void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise |
7007
d335c6daf964
(svn r10263) -Fix (r10262): due to 64 bits alignment a struct became a little too large.
rubidium
parents:
7006
diff
changeset
|
1250 |
uint64 params[10]; ///< local copy of _decode_parameters |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1251 |
StringID message; ///< message shown for query window |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1252 |
bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
1253 |
}; |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1254 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1255 |
|
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1256 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1257 |
static void QueryWndProc(Window *w, WindowEvent *e) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1258 |
{ |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1259 |
query_d *q = &WP(w, query_d); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1260 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1261 |
switch (e->event) { |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1262 |
case WE_PAINT: |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7241
diff
changeset
|
1263 |
CopyInDParam(0, q->params, lengthof(q->params)); |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1264 |
DrawWindowWidgets(w); |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7241
diff
changeset
|
1265 |
CopyInDParam(0, q->params, lengthof(q->params)); |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1266 |
|
6197
558f3a9b5bd4
(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:
6190
diff
changeset
|
1267 |
DrawStringMultiCenter(w->width / 2, (w->height / 2) - 10, q->message, w->width - 2); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1268 |
break; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1269 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1270 |
case WE_CLICK: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1271 |
switch (e->we.click.widget) { |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1272 |
case QUERY_WIDGET_YES: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1273 |
q->calledback = true; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1274 |
if (q->proc != NULL) q->proc(w->parent, true); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1275 |
/* Fallthrough */ |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1276 |
case QUERY_WIDGET_NO: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1277 |
DeleteWindow(w); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1278 |
break; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1279 |
} |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1280 |
break; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1281 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1282 |
case WE_KEYPRESS: // ESC closes the window, Enter confirms the action |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1283 |
switch (e->we.keypress.keycode) { |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1284 |
case WKC_RETURN: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1285 |
case WKC_NUM_ENTER: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1286 |
q->calledback = true; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1287 |
if (q->proc != NULL) q->proc(w->parent, true); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1288 |
/* Fallthrough */ |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1289 |
case WKC_ESC: |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1290 |
e->we.keypress.cont = false; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1291 |
DeleteWindow(w); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1292 |
break; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1293 |
} |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1294 |
break; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1295 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1296 |
case WE_DESTROY: // Call callback function (if any) on window close if not yet called |
5429
a664da42d64e
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5418
diff
changeset
|
1297 |
if (!q->calledback && q->proc != NULL) { |
a664da42d64e
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5418
diff
changeset
|
1298 |
q->calledback = true; |
a664da42d64e
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5418
diff
changeset
|
1299 |
q->proc(w->parent, false); |
a664da42d64e
(svn r7635) -Fix (r7618, r7621): Guard against recursive deletion. It is possible that when a
Darkvater
parents:
5418
diff
changeset
|
1300 |
} |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1301 |
break; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1302 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1303 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1304 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1305 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1306 |
static const Widget _query_widgets[] = { |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1307 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1308 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 209, 0, 13, STR_NULL, STR_NULL}, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1309 |
{ WWT_PANEL, RESIZE_NONE, 4, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL}, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1310 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 20, 90, 62, 73, STR_00C9_NO, STR_NULL}, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1311 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 120, 190, 62, 73, STR_00C8_YES, STR_NULL}, |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1312 |
{ WIDGETS_END }, |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1313 |
}; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1314 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1315 |
static const WindowDesc _query_desc = { |
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
1316 |
WDP_CENTER, WDP_CENTER, 210, 82, 210, 82, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
1317 |
WC_CONFIRM_POPUP_QUERY, WC_NONE, |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1318 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL, |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1319 |
_query_widgets, |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1320 |
QueryWndProc |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1321 |
}; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1322 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1323 |
/** Show a modal confirmation window with standard 'yes' and 'no' buttons |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1324 |
* The window is aligned to the centre of its parent. |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1325 |
* NOTE: You cannot use BindCString as parameter for this window! |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1326 |
* @param caption string shown as window caption |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1327 |
* @param message string that will be shown for the window |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1328 |
* @param parent pointer to parent window, if this pointer is NULL the parent becomes |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1329 |
* the main window WC_MAIN_WINDOW |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
1330 |
* @param callback callback function pointer to set in the window descriptor*/ |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1331 |
void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1332 |
{ |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1333 |
Window *w = AllocateWindowDesc(&_query_desc); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1334 |
if (w == NULL) return; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1335 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1336 |
if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1337 |
w->parent = parent; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1338 |
w->left = parent->left + (parent->width / 2) - (w->width / 2); |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1339 |
w->top = parent->top + (parent->height / 2) - (w->height / 2); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1340 |
|
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1341 |
/* Create a backup of the variadic arguments to strings because it will be |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1342 |
* overridden pretty often. We will copy these back for drawing */ |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7241
diff
changeset
|
1343 |
CopyOutDParam(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); |
5418
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1344 |
w->widget[QUERY_WIDGET_CAPTION].data = caption; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1345 |
WP(w, query_d).message = message; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1346 |
WP(w, query_d).proc = callback; |
793a133c6d2a
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5380
diff
changeset
|
1347 |
WP(w, query_d).calledback = false; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1348 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1349 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1350 |
|
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1351 |
static const Widget _load_dialog_widgets[] = { |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1352 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1353 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1354 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1355 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1356 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1357 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 153, 0x0, STR_NULL}, |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1358 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1359 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 151, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1360 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 141, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1361 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 142, 153, 0x0, STR_RESIZE_BUTTON}, |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1362 |
{ WIDGETS_END}, |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1363 |
}; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1364 |
|
0 | 1365 |
static const Widget _save_dialog_widgets[] = { |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1366 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1367 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1368 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1369 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1370 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1371 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 151, 0x0, STR_NULL}, |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1372 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1373 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 150, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1374 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 151, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1375 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 256, 152, 167, 0x0, STR_NULL}, |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1376 |
{ WWT_EDITBOX, RESIZE_RTB, 14, 2, 254, 154, 165, STR_SAVE_OSKTITLE,STR_400B_CURRENTLY_SELECTED_NAME}, |
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1377 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 127, 168, 179, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1378 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 128, 244, 168, 179, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING}, |
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1379 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 168, 179, 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
|
1380 |
{ WIDGETS_END}, |
0 | 1381 |
}; |
1382 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1383 |
/* Colors for fios types */ |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1384 |
const TextColour _fios_colors[] = { |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1385 |
TC_LIGHT_BLUE, TC_DARK_GREEN, TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN, |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1386 |
TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1387 |
}; |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2255
diff
changeset
|
1388 |
|
6247 | 1389 |
void BuildFileList() |
0 | 1390 |
{ |
1596
483007886b59
(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
|
1391 |
_fios_path_changed = true; |
0 | 1392 |
FiosFreeSavegameList(); |
4223
d4c9ef555f43
(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
|
1393 |
|
2549 | 1394 |
switch (_saveload_mode) { |
1395 |
case SLD_NEW_GAME: |
|
1396 |
case SLD_LOAD_SCENARIO: |
|
1397 |
case SLD_SAVE_SCENARIO: |
|
4223
d4c9ef555f43
(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
|
1398 |
_fios_list = FiosGetScenarioList(_saveload_mode); break; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1399 |
case SLD_LOAD_HEIGHTMAP: |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1400 |
_fios_list = FiosGetHeightmapList(_saveload_mode); break; |
2549 | 1401 |
|
4223
d4c9ef555f43
(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
|
1402 |
default: _fios_list = FiosGetSavegameList(_saveload_mode); break; |
2549 | 1403 |
} |
0 | 1404 |
} |
1405 |
||
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1406 |
static void DrawFiosTexts(uint maxw) |
0 | 1407 |
{ |
1596
483007886b59
(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
|
1408 |
static const char *path = NULL; |
483007886b59
(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
|
1409 |
static StringID str = STR_4006_UNABLE_TO_READ_DRIVE; |
483007886b59
(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
|
1410 |
static uint32 tot = 0; |
0 | 1411 |
|
1596
483007886b59
(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
|
1412 |
if (_fios_path_changed) { |
483007886b59
(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
|
1413 |
str = FiosGetDescText(&path, &tot); |
483007886b59
(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
|
1414 |
_fios_path_changed = false; |
483007886b59
(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
|
1415 |
} |
483007886b59
(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
|
1416 |
|
483007886b59
(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
|
1417 |
if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1418 |
DrawString(2, 37, str, TC_FROMSTRING); |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7750
diff
changeset
|
1419 |
DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw); |
0 | 1420 |
} |
1421 |
||
6247 | 1422 |
static void MakeSortedSaveGameList() |
0 | 1423 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1424 |
uint sort_start = 0; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1425 |
uint sort_end = 0; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1426 |
uint s_amount; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1427 |
int i; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1428 |
|
4171 | 1429 |
/* Directories are always above the files (FIOS_TYPE_DIR) |
1430 |
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE) |
|
1431 |
* Only sort savegames/scenarios, not directories |
|
0 | 1432 |
*/ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1433 |
for (i = 0; i < _fios_num; i++) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1434 |
switch (_fios_list[i].type) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1435 |
case FIOS_TYPE_DIR: sort_start++; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1436 |
case FIOS_TYPE_PARENT: sort_start++; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1437 |
case FIOS_TYPE_DRIVE: sort_end++; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1438 |
} |
0 | 1439 |
} |
1440 |
||
1441 |
s_amount = _fios_num - sort_start - sort_end; |
|
1105 | 1442 |
if (s_amount > 0) |
0 | 1443 |
qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems); |
1444 |
} |
|
1445 |
||
6247 | 1446 |
static void GenerateFileName() |
402
457f7c7022e3
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1447 |
{ |
8748 | 1448 |
/* Check if we are not a spectator who wants to generate a name.. |
635
38f9209f5caa
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1449 |
Let's use the name of player #0 for now. */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1450 |
const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
635
38f9209f5caa
(svn r1066) -Fix: Crash when saving game as spectator (tnx to GeniusDex for reporting)
truelight
parents:
606
diff
changeset
|
1451 |
|
7058
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7046
diff
changeset
|
1452 |
SetDParam(0, p->index); |
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7046
diff
changeset
|
1453 |
SetDParam(1, _date); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
1454 |
GetString(_edit_str_buf, STR_4004, lastof(_edit_str_buf)); |
6875
e517a59b78e5
(svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.
rubidium
parents:
6691
diff
changeset
|
1455 |
SanitizeFilename(_edit_str_buf); |
402
457f7c7022e3
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1456 |
} |
457f7c7022e3
(svn r594) -Fix/Feature: [ 1066121 ] Resetting file name after deleting a file
tron
parents:
390
diff
changeset
|
1457 |
|
6247 | 1458 |
extern void StartupEngines(); |
1131
305545b1f671
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1459 |
|
0 | 1460 |
static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) |
1461 |
{ |
|
2559
fe757666278c
(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
|
1462 |
static FiosItem o_dir; |
fe757666278c
(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
|
1463 |
|
fe757666278c
(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
|
1464 |
switch (e->event) { |
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1465 |
case WE_CREATE: // Set up OPENTTD button |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1466 |
w->vscroll.cap = 10; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1467 |
w->resize.step_width = 2; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1468 |
w->resize.step_height = 10; |
0 | 1469 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1470 |
o_dir.type = FIOS_TYPE_DIRECT; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1471 |
switch (_saveload_mode) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1472 |
case SLD_SAVE_GAME: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1473 |
case SLD_LOAD_GAME: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1474 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1475 |
break; |
4000
4009d092b306
(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
|
1476 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1477 |
case SLD_SAVE_SCENARIO: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1478 |
case SLD_LOAD_SCENARIO: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1479 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1480 |
break; |
0 | 1481 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1482 |
case SLD_LOAD_HEIGHTMAP: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1483 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1484 |
break; |
4000
4009d092b306
(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 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1486 |
default: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1487 |
ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1488 |
} |
0 | 1489 |
break; |
1490 |
||
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1491 |
case WE_PAINT: { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1492 |
int pos; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1493 |
int y; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1494 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1495 |
SetVScrollCount(w, _fios_num); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1496 |
DrawWindowWidgets(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1497 |
DrawFiosTexts(w->width); |
2100
217ea6fdfd18
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1498 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1499 |
if (_savegame_sort_dirty) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1500 |
_savegame_sort_dirty = false; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1501 |
MakeSortedSaveGameList(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1502 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1503 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1504 |
GfxFillRect(w->widget[7].left + 1, w->widget[7].top + 1, w->widget[7].right, w->widget[7].bottom, 0xD7); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1505 |
DrawSortButtonState(w, _savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1506 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1507 |
y = w->widget[7].top + 1; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1508 |
for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1509 |
const FiosItem *item = _fios_list + pos; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1510 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1511 |
DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1512 |
y += 10; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1513 |
if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1514 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1515 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1516 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1517 |
DrawEditBox(w, &WP(w, querystr_d), 10); |
0 | 1518 |
} |
1519 |
break; |
|
1520 |
} |
|
2559
fe757666278c
(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
|
1521 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1522 |
case WE_CLICK: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1523 |
switch (e->we.click.widget) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1524 |
case 2: // Sort save names by name |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1525 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ? |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1526 |
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1527 |
_savegame_sort_dirty = true; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1528 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1529 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1530 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1531 |
case 3: // Sort save names by date |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1532 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ? |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1533 |
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1534 |
_savegame_sort_dirty = true; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1535 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1536 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1537 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1538 |
case 6: // OpenTTD 'button', jumps to OpenTTD directory |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1539 |
FiosBrowseTo(&o_dir); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1540 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1541 |
BuildFileList(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1542 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1543 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1544 |
case 7: { // Click the listbox |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1545 |
int y = (e->we.click.pt.y - w->widget[e->we.click.widget].top - 1) / 10; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1546 |
char *name; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1547 |
const FiosItem *file; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1548 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1549 |
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1550 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1551 |
file = _fios_list + y; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1552 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1553 |
name = FiosBrowseTo(file); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1554 |
if (name != NULL) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1555 |
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1556 |
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1557 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1558 |
SetFiosType(file->type); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1559 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1560 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1561 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1562 |
DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1563 |
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1564 |
SetFiosType(file->type); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1565 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1566 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1567 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1568 |
DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1569 |
ShowHeightmapLoad(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1570 |
} else { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1571 |
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1572 |
ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1573 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1574 |
w->InvalidateWidget(10); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1575 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1576 |
} else { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1577 |
/* Changed directory, need repaint. */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1578 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1579 |
BuildFileList(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1580 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1581 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1582 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1583 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1584 |
case 10: // edit box |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1585 |
ShowOnScreenKeyboard(w, &WP(w, querystr_d), e->we.click.widget, 0, 0); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1586 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1587 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1588 |
case 11: case 12: // Delete, Save game |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1589 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1590 |
} |
8737
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1591 |
break; |
4405e2e80db6
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents:
8715
diff
changeset
|
1592 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1593 |
case WE_MOUSELOOP: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1594 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1595 |
HandleEditBox(w, &WP(w, querystr_d), 10); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1596 |
} |
0 | 1597 |
break; |
2165
ae3653f5ee34
(svn r2675) - Fix: pressing enter on a load-window resulted in saving the game (Luca)
Darkvater
parents:
2163
diff
changeset
|
1598 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1599 |
case WE_KEYPRESS: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1600 |
if (e->we.keypress.keycode == WKC_ESC) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1601 |
DeleteWindow(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1602 |
return; |
2255
fd5d5adee9d9
(svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents:
2201
diff
changeset
|
1603 |
} |
3288
5e0c047edca4
(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
|
1604 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1605 |
if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) && |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1606 |
HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) { // Press Enter |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1607 |
w->HandleButtonClick(12); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1608 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1609 |
break; |
1131
305545b1f671
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1610 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1611 |
case WE_TIMEOUT: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1612 |
/* This test protects against using widgets 11 and 12 which are only available |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1613 |
* in those two saveload mode */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1614 |
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1615 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1616 |
if (w->IsWidgetLowered(11)) { // Delete button clicked |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1617 |
if (!FiosDelete(WP(w, querystr_d).text.buf)) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1618 |
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1619 |
} else { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1620 |
BuildFileList(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1621 |
/* Reset file name to current date on successful delete */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1622 |
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1623 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1624 |
|
8738
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1625 |
UpdateTextBufferSize(&WP(w, querystr_d).text); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1626 |
SetWindowDirty(w); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1627 |
} else if (w->IsWidgetLowered(12)) { // Save button clicked |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1628 |
_switch_mode = SM_SAVE; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1629 |
FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name)); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1630 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1631 |
/* In the editor set up the vehicle engines correctly (date might have changed) */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1632 |
if (_game_mode == GM_EDITOR) StartupEngines(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1633 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1634 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1635 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1636 |
case WE_DESTROY: |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1637 |
/* pause is only used in single-player, non-editor mode, non menu mode */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1638 |
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1639 |
if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1640 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1641 |
FiosFreeSavegameList(); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1642 |
ClrBit(_no_scroll, SCROLL_SAVE); |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1643 |
break; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1644 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1645 |
case WE_RESIZE: { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1646 |
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1647 |
uint diff = e->we.sizing.diff.x / 2; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1648 |
w->widget[2].right += diff; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1649 |
w->widget[3].left += diff; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1650 |
w->widget[3].right += e->we.sizing.diff.x; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1651 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1652 |
/* Same for widget 11 and 12 in save-dialog */ |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1653 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1654 |
w->widget[11].right += diff; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1655 |
w->widget[12].left += diff; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1656 |
w->widget[12].right += e->we.sizing.diff.x; |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1657 |
} |
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1658 |
|
05aca6d9471b
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
rubidium
parents:
8737
diff
changeset
|
1659 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1660 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1661 |
} |
0 | 1662 |
} |
1663 |
||
1664 |
static const WindowDesc _load_dialog_desc = { |
|
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1665 |
WDP_CENTER, WDP_CENTER, 257, 154, 257, 294, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
1666 |
WC_SAVELOAD, WC_NONE, |
8019
fc0e94dee165
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8018
diff
changeset
|
1667 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1668 |
_load_dialog_widgets, |
0 | 1669 |
SaveLoadDlgWndProc, |
1670 |
}; |
|
1671 |
||
1672 |
static const WindowDesc _save_dialog_desc = { |
|
7346
dcfda6aa096f
(svn r10709) -Codechange: allow automatic downsizing of the load game/save game windows. These windows also already supported downsizing, but again the resize button would be unreachable.
rubidium
parents:
7341
diff
changeset
|
1673 |
WDP_CENTER, WDP_CENTER, 257, 180, 257, 320, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
1674 |
WC_SAVELOAD, WC_NONE, |
8019
fc0e94dee165
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents:
8018
diff
changeset
|
1675 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1676 |
_save_dialog_widgets, |
1677 |
SaveLoadDlgWndProc, |
|
1678 |
}; |
|
1679 |
||
8152
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1680 |
/** These values are used to convert the file/operations mode into a corresponding file type. |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1681 |
* So each entry, as expressed by the related comment, is based on the enum */ |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1682 |
static const FileType _file_modetotype[] = { |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1683 |
FT_SAVEGAME, ///< used for SLD_LOAD_GAME |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1684 |
FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1685 |
FT_SAVEGAME, ///< used for SLD_SAVE_GAME |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1686 |
FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1687 |
FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1688 |
FT_SAVEGAME, ///< SLD_NEW_GAME |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1689 |
}; |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1690 |
|
8149
1b1390cb0844
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents:
8144
diff
changeset
|
1691 |
void ShowSaveLoadDialog(SaveLoadDialogMode mode) |
0 | 1692 |
{ |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1693 |
static const StringID saveload_captions[] = { |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1694 |
STR_4001_LOAD_GAME, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1695 |
STR_0298_LOAD_SCENARIO, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1696 |
STR_4000_SAVE_GAME, |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1697 |
STR_0299_SAVE_SCENARIO, |
8424
c3477565c975
(svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents:
8423
diff
changeset
|
1698 |
STR_LOAD_HEIGHTMAP, |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1699 |
}; |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1700 |
|
0 | 1701 |
Window *w; |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1702 |
const WindowDesc *sld = &_save_dialog_desc; |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1703 |
|
0 | 1704 |
|
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7859
diff
changeset
|
1705 |
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
0 | 1706 |
DeleteWindowById(WC_QUERY_STRING, 0); |
1707 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1708 |
||
1709 |
_saveload_mode = mode; |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
1710 |
SetBit(_no_scroll, SCROLL_SAVE); |
1397
fa8539dcab46
(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
|
1711 |
|
8152
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1712 |
/* Use an array to define what will be the current file type being handled |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1713 |
* by current file mode */ |
ab21de45f8ab
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents:
8149
diff
changeset
|
1714 |
_file_to_saveload.filetype = _file_modetotype[mode]; |
1397
fa8539dcab46
(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
|
1715 |
switch (mode) { |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1716 |
case SLD_SAVE_GAME: GenerateFileName(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1717 |
case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1718 |
default: sld = &_load_dialog_desc; break; |
1397
fa8539dcab46
(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
|
1719 |
} |
0 | 1720 |
|
5079
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1721 |
assert((uint)mode < lengthof(saveload_captions)); |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1722 |
w = AllocateWindowDesc(sld); |
15816766b4ee
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1723 |
w->widget[1].data = saveload_captions[mode]; |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
1724 |
w->LowerWidget(7); |
4948
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1725 |
|
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1726 |
WP(w, querystr_d).afilter = CS_ALPHANUMERAL; |
22ff05c1a3b1
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
1727 |
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240); |
0 | 1728 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1729 |
/* pause is only used in single-player, non-editor mode, non-menu mode. It |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1730 |
* will be unpaused in the WE_DESTROY event handler. */ |
2639 | 1731 |
if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { |
8671
577d7a43978b
(svn r12336) -Fix [FS#1733]: Don't pause/unpause the game when showing load/save windows when the game is paused due to missing GRFs.
peter1138
parents:
8623
diff
changeset
|
1732 |
if (_pause_game >= 0) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
2639 | 1733 |
} |
278
a0a9b0d903aa
(svn r284) Fix: on opening the saveload dialog the game pauses again in single player games
dominik
parents:
258
diff
changeset
|
1734 |
|
0 | 1735 |
BuildFileList(); |
1736 |
||
1737 |
ResetObjectToPlace(); |
|
1738 |
} |
|
1739 |
||
6247 | 1740 |
void RedrawAutosave() |
0 | 1741 |
{ |
1742 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
|
1743 |
} |
|
1744 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1745 |
void SetFiosType(const byte fiostype) |
0 | 1746 |
{ |
1747 |
switch (fiostype) { |
|
2549 | 1748 |
case FIOS_TYPE_FILE: |
1749 |
case FIOS_TYPE_SCENARIO: |
|
1750 |
_file_to_saveload.mode = SL_LOAD; |
|
1751 |
break; |
|
1752 |
||
1753 |
case FIOS_TYPE_OLDFILE: |
|
1754 |
case FIOS_TYPE_OLD_SCENARIO: |
|
1755 |
_file_to_saveload.mode = SL_OLD_LOAD; |
|
1756 |
break; |
|
1757 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1758 |
#ifdef WITH_PNG |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1759 |
case FIOS_TYPE_PNG: |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1760 |
_file_to_saveload.mode = SL_PNG; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1761 |
break; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1762 |
#endif /* WITH_PNG */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1763 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1764 |
case FIOS_TYPE_BMP: |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1765 |
_file_to_saveload.mode = SL_BMP; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1766 |
break; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1767 |
|
2549 | 1768 |
default: |
1769 |
_file_to_saveload.mode = SL_INVALID; |
|
1770 |
break; |
|
0 | 1771 |
} |
1772 |
} |
|
1773 |
||
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1774 |
/** |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1775 |
* The 'amount' to cheat with. |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1776 |
* This variable is semantically a constant value, but because the cheat |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1777 |
* code requires to be able to write to the variable it is not constified. |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1778 |
*/ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1779 |
static int32 _money_cheat_amount = 10000000; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1780 |
|
410 | 1781 |
static int32 ClickMoneyCheat(int32 p1, int32 p2) |
0 | 1782 |
{ |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1783 |
DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, NULL, CMD_MONEY_CHEAT); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1784 |
return _money_cheat_amount; |
0 | 1785 |
} |
1786 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1787 |
/** |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1788 |
* @param p1 player to set to |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1789 |
* @param p2 is -1 or +1 (down/up) |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1790 |
*/ |
410 | 1791 |
static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
0 | 1792 |
{ |
4850
93095755db8c
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4834
diff
changeset
|
1793 |
while (IsValidPlayer((PlayerID)p1)) { |
2639 | 1794 |
if (_players[p1].is_active) { |
5376
204acb84473f
(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
|
1795 |
SetLocalPlayer((PlayerID)p1); |
204acb84473f
(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
|
1796 |
|
138
6ab4d97d1034
(svn r139) Added MarkWholeScreenDirty() on switch player screen
dominik
parents:
108
diff
changeset
|
1797 |
MarkWholeScreenDirty(); |
0 | 1798 |
return _local_player; |
1799 |
} |
|
1800 |
p1 += p2; |
|
1801 |
} |
|
155
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1802 |
|
81e9878f3678
(svn r156) -Codechange: remove obsolete callback arrays
darkvater
parents:
147
diff
changeset
|
1803 |
return _local_player; |
0 | 1804 |
} |
1805 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1806 |
/** |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1807 |
* @param p1 -1 or +1 (down/up) |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
1808 |
* @param p2 unused |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1809 |
*/ |
1095 | 1810 |
static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
100 | 1811 |
{ |
2639 | 1812 |
if (p1 == -1) p1 = 3; |
1813 |
if (p1 == 4) p1 = 0; |
|
100 | 1814 |
_opt.landscape = p1; |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
1815 |
ReloadNewGRFData(); |
100 | 1816 |
return _opt.landscape; |
1817 |
} |
|
1818 |
||
6247 | 1819 |
extern void EnginesMonthlyLoop(); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1820 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1821 |
/** |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6453
diff
changeset
|
1822 |
* @param p1 unused |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1823 |
* @param p2 1 (increase) or -1 (decrease) |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1824 |
*/ |
1095 | 1825 |
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
|
1826 |
{ |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1827 |
YearMonthDay ymd; |
4288
393de75451b1
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
1828 |
ConvertDateToYMD(_date, &ymd); |
108
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1829 |
|
4293
4b7006c1b5eb
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
1830 |
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
|
1831 |
|
4288
393de75451b1
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
1832 |
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
|
1833 |
EnginesMonthlyLoop(); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1834 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1835 |
return _cur_year; |
8e2e584a9500
(svn r109) added/heavily modified patch by truesatan: cheat change date
dominik
parents:
104
diff
changeset
|
1836 |
} |
100 | 1837 |
|
0 | 1838 |
typedef int32 CheckButtonClick(int32, int32); |
1839 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
1840 |
struct CheatEntry { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1841 |
VarType type; ///< type of selector |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1842 |
StringID str; ///< string with descriptive text |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1843 |
void *variable; ///< pointer to the variable |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1844 |
bool *been_used; ///< has this cheat been used before? |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6197
diff
changeset
|
1845 |
CheckButtonClick *proc;///< procedure |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
1846 |
}; |
0 | 1847 |
|
1848 |
static const CheatEntry _cheats_ui[] = { |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1849 |
{SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1850 |
{SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1851 |
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1852 |
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1853 |
{SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1854 |
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1855 |
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL }, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1856 |
{SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat}, |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1857 |
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat }, |
0 | 1858 |
}; |
1859 |
||
1860 |
||
1861 |
static const Widget _cheat_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
1862 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
1863 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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
|
1864 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1865 |
{ 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
|
1866 |
{ WIDGETS_END}, |
0 | 1867 |
}; |
1868 |
||
1869 |
static void CheatsWndProc(Window *w, WindowEvent *e) |
|
1870 |
{ |
|
2639 | 1871 |
switch (e->event) { |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1872 |
case WE_PAINT: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1873 |
int clk = WP(w, def_d).data_1; |
2639 | 1874 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1875 |
DrawWindowWidgets(w); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1876 |
DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50); |
3110
53cc5f8754aa
(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
|
1877 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1878 |
for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1879 |
const CheatEntry *ce = &_cheats_ui[i]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1880 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1881 |
DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, x + 5, y + 2); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1882 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1883 |
switch (ce->type) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1884 |
case SLE_BOOL: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1885 |
bool on = (*(bool*)ce->variable); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1886 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1887 |
DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, on ? 6 : 4, on ? FR_LOWERED : FR_NONE); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1888 |
SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1889 |
} break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1890 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1891 |
default: { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1892 |
int32 val = (int32)ReadValue(ce->variable, ce->type); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1893 |
char buf[512]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1894 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1895 |
/* Draw [<][>] boxes for settings of an integer-type */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1896 |
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1897 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1898 |
switch (ce->str) { |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1899 |
/* Display date for change date cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1900 |
case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1901 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1902 |
/* Draw colored flag for change player cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1903 |
case STR_CHEAT_CHANGE_PLAYER: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1904 |
SetDParam(0, val); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1905 |
GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf)); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1906 |
DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1907 |
break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1908 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1909 |
/* Set correct string for switch climate cheat */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1910 |
case STR_CHEAT_SWITCH_CLIMATE: val += STR_TEMPERATE_LANDSCAPE; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1911 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1912 |
/* Fallthrough */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1913 |
default: SetDParam(0, val); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1914 |
} |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1915 |
} break; |
2639 | 1916 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1917 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1918 |
DrawString(50, y + 1, ce->str, TC_FROMSTRING); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1919 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1920 |
y += 12; |
0 | 1921 |
} |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1922 |
break; |
0 | 1923 |
} |
2639 | 1924 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1925 |
case WE_CLICK: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1926 |
uint btn = (e->we.click.pt.y - 46) / 12; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4609
diff
changeset
|
1927 |
uint x = e->we.click.pt.x; |
0 | 1928 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1929 |
/* Not clicking a button? */ |
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7931
diff
changeset
|
1930 |
if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) break; |
0 | 1931 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1932 |
const CheatEntry *ce = &_cheats_ui[btn]; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1933 |
int value = (int32)ReadValue(ce->variable, ce->type); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1934 |
int oldvalue = value; |
0 | 1935 |
|
1936 |
*ce->been_used = true; |
|
1937 |
||
2639 | 1938 |
switch (ce->type) { |
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1939 |
case SLE_BOOL: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1940 |
value ^= 1; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1941 |
if (ce->proc != NULL) ce->proc(value, 0); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1942 |
break; |
0 | 1943 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1944 |
default: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1945 |
/* Take whatever the function returns */ |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1946 |
value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1); |
0 | 1947 |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1948 |
if (value != oldvalue) WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1949 |
break; |
0 | 1950 |
} |
1951 |
||
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1952 |
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value); |
0 | 1953 |
|
1954 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
|
1955 |
||
1956 |
SetWindowDirty(w); |
|
8715
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1957 |
} break; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1958 |
|
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1959 |
case WE_TIMEOUT: |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1960 |
WP(w, def_d).data_1 = 0; |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1961 |
SetWindowDirty(w); |
26eb4dd8f515
(svn r12389) -Codechange: remove unneeded code from the Cheat window handling and bring it in line with the coding guidelines.
rubidium
parents:
8671
diff
changeset
|
1962 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1963 |
} |
0 | 1964 |
} |
2639 | 1965 |
|
0 | 1966 |
static const WindowDesc _cheats_desc = { |
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7321
diff
changeset
|
1967 |
240, 22, 400, 170, 400, 170, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5750
diff
changeset
|
1968 |
WC_CHEATS, WC_NONE, |
0 | 1969 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1970 |
_cheat_widgets, |
|
1971 |
CheatsWndProc |
|
1972 |
}; |
|
1973 |
||
1974 |
||
6247 | 1975 |
void ShowCheatWindow() |
0 | 1976 |
{ |
1977 |
DeleteWindowById(WC_CHEATS, 0); |
|
5137
54425dc8b5b3
(svn r7219) -Fix: Several warnings by gcc introduced in r7206 which MSVC found not of a problem. Thanks Tron
Darkvater
parents:
5125
diff
changeset
|
1978 |
AllocateWindowDesc(&_cheats_desc); |
0 | 1979 |
} |