author | glx |
Mon, 19 May 2008 15:13:58 +0000 | |
branch | noai |
changeset 10645 | 8cbdb511a674 |
parent 10513 | 33cb70ff2f5d |
child 10715 | 6bdf79ffb022 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3 |
/** @file misc_gui.cpp GUIs for a number of misc windows. */ |
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1879
diff
changeset
|
6 |
#include "openttd.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
7 |
#include "heightmap.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1274
diff
changeset
|
8 |
#include "debug.h" |
9599 | 9 |
#include "landscape.h" |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5320
diff
changeset
|
10 |
#include "newgrf.h" |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
11 |
#include "newgrf_text.h" |
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
2159
diff
changeset
|
12 |
#include "saveload.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
13 |
#include "tile_map.h" |
0 | 14 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
15 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
16 |
#include "station_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "textbuf_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
19 |
#include "gfx_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
20 |
#include "station_func.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
21 |
#include "command_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
22 |
#include "player_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
23 |
#include "player_base.h" |
0 | 24 |
#include "town.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5698
diff
changeset
|
25 |
#include "network/network.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2134
diff
changeset
|
26 |
#include "variables.h" |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
27 |
#include "cheat_func.h" |
3890
f8f13a91446a
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents:
3798
diff
changeset
|
28 |
#include "train.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
29 |
#include "tgp.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
30 |
#include "cargotype.h" |
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6417
diff
changeset
|
31 |
#include "player_face.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
32 |
#include "strings_func.h" |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
33 |
#include "fileio.h" |
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
34 |
#include "fios.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
35 |
#include "tile_cmd.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
36 |
#include "zoom_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
37 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
38 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
39 |
#include "date_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
40 |
#include "sound_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
41 |
#include "string_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
42 |
#include "player_gui.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
43 |
#include "settings_type.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
44 |
#include "newgrf_cargo.h" |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
45 |
#include "rail_gui.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
46 |
#include "tilehighlight_func.h" |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
47 |
#include "querystring_gui.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
48 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
49 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
50 |
#include "table/strings.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
51 |
|
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
52 |
/* Variables to display file lists */ |
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
53 |
FiosItem *_fios_list; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
54 |
SaveLoadDialogMode _saveload_mode; |
0 | 55 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
56 |
|
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
57 |
static bool _fios_path_changed; |
1594
1cbbb77f5bb2
(svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents:
1578
diff
changeset
|
58 |
static bool _savegame_sort_dirty; |
1cbbb77f5bb2
(svn r2098) Make a variable static, move a function declaration to a header and remove unnecessary preprocessor magic
tron
parents:
1578
diff
changeset
|
59 |
|
0 | 60 |
static const Widget _land_info_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
61 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
62 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
63 |
{ 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
|
64 |
{ WIDGETS_END}, |
0 | 65 |
}; |
66 |
||
67 |
static const WindowDesc _land_info_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
68 |
WDP_AUTO, WDP_AUTO, 280, 93, 280, 93, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
69 |
WC_LAND_INFO, WC_NONE, |
0 | 70 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
71 |
_land_info_widgets, |
|
72 |
}; |
|
73 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
74 |
class LandInfoWindow : public Window { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
75 |
enum { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
76 |
LAND_INFO_LINES = 7, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
77 |
LAND_INFO_LINE_BUFF_SIZE = 512, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
78 |
}; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
79 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
80 |
public: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
81 |
char landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
82 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
83 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
84 |
{ |
10645 | 85 |
this->DrawWidgets(); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
86 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
87 |
DoDrawStringCentered(140, 16, this->landinfo_data[0], TC_LIGHT_BLUE); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
88 |
DoDrawStringCentered(140, 27, this->landinfo_data[1], TC_FROMSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
89 |
DoDrawStringCentered(140, 38, this->landinfo_data[2], TC_FROMSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
90 |
DoDrawStringCentered(140, 49, this->landinfo_data[3], TC_FROMSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
91 |
DoDrawStringCentered(140, 60, this->landinfo_data[4], TC_FROMSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
92 |
if (!StrEmpty(this->landinfo_data[5])) DrawStringMultiCenter(140, 76, BindCString(this->landinfo_data[5]), this->width - 4); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
93 |
if (!StrEmpty(this->landinfo_data[6])) DoDrawStringCentered(140, 71, this->landinfo_data[6], TC_FROMSTRING); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
94 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
95 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
96 |
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
97 |
Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
98 |
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
99 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
100 |
Money old_money = p->player_money; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
101 |
p->player_money = INT64_MAX; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
102 |
CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
103 |
p->player_money = old_money; |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
104 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
105 |
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
106 |
TileDesc td; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
107 |
AcceptedCargo ac; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
108 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
109 |
td.build_date = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
110 |
GetAcceptedCargo(tile, ac); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
111 |
GetTileDesc(tile, &td); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
112 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
113 |
SetDParam(0, td.dparam[0]); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
114 |
GetString(this->landinfo_data[0], td.str, lastof(this->landinfo_data[0])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
115 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
116 |
SetDParam(0, STR_01A6_N_A); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
117 |
if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
118 |
GetString(this->landinfo_data[1], STR_01A7_OWNER, lastof(this->landinfo_data[1])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
119 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
120 |
StringID str = STR_01A4_COST_TO_CLEAR_N_A; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
121 |
if (CmdSucceeded(costclear)) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
122 |
SetDParam(0, costclear.GetCost()); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
123 |
str = STR_01A5_COST_TO_CLEAR; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
124 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
125 |
GetString(this->landinfo_data[2], str, lastof(this->landinfo_data[2])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
126 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
127 |
snprintf(_userstring, lengthof(_userstring), "0x%.4X", tile); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
128 |
SetDParam(0, TileX(tile)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
129 |
SetDParam(1, TileY(tile)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
130 |
SetDParam(2, TileHeight(tile)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
131 |
SetDParam(3, STR_SPEC_USERSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
132 |
GetString(this->landinfo_data[3], STR_LANDINFO_COORDS, lastof(this->landinfo_data[3])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
133 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
134 |
SetDParam(0, STR_01A9_NONE); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
135 |
if (t != NULL && t->IsValid()) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
136 |
SetDParam(0, STR_TOWN); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
137 |
SetDParam(1, t->index); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
138 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
139 |
GetString(this->landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[4])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
140 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
141 |
char *strp = GetString(this->landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[5])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
142 |
bool found = false; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
143 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
144 |
for (CargoID i = 0; i < NUM_CARGO; ++i) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
145 |
if (ac[i] > 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
146 |
/* Add a comma between each item. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
147 |
if (found) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
148 |
*strp++ = ','; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
149 |
*strp++ = ' '; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
150 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
151 |
found = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
152 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
153 |
/* If the accepted value is less than 8, show it in 1/8:ths */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
154 |
if (ac[i] < 8) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
155 |
SetDParam(0, ac[i]); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
156 |
SetDParam(1, GetCargo(i)->name); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
157 |
strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[5])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
158 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
159 |
strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[5])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
160 |
} |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
161 |
} |
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
162 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
163 |
if (!found) this->landinfo_data[5][0] = '\0'; |
5834
7bf92d5a5a0f
(svn r8030) -Fix: segmentation fault when removing a town in the scenario editor while having the query tool window open for one of the town's tiles.
rubidium
parents:
5726
diff
changeset
|
164 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
165 |
if (td.build_date != 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
166 |
SetDParam(0, td.build_date); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
167 |
GetString(this->landinfo_data[6], STR_BUILD_DATE, lastof(this->landinfo_data[6])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
168 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
169 |
this->landinfo_data[6][0] = '\0'; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
170 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
171 |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
172 |
#if defined(_DEBUG) |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
173 |
# define LANDINFOD_LEVEL 0 |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
174 |
#else |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
175 |
# define LANDINFOD_LEVEL 1 |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
176 |
#endif |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
177 |
DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
178 |
DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
179 |
DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
180 |
DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
181 |
DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
182 |
DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
183 |
DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
184 |
DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _m[tile].m6); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
185 |
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7); |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
186 |
#undef LANDINFOD_LEVEL |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
187 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
188 |
this->FindWindowPlacementAndResize(&_land_info_desc); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
189 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
190 |
}; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
191 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
192 |
static void Place_LandInfo(TileIndex tile) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
193 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
194 |
DeleteWindowById(WC_LAND_INFO, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
195 |
new LandInfoWindow(tile); |
0 | 196 |
} |
197 |
||
6573 | 198 |
void PlaceLandBlockInfo() |
0 | 199 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
200 |
if (_cursor.sprite == SPR_CURSOR_QUERY) { |
0 | 201 |
ResetObjectToPlace(); |
202 |
} else { |
|
203 |
_place_proc = Place_LandInfo; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
204 |
SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0); |
0 | 205 |
} |
206 |
} |
|
207 |
||
208 |
static const Widget _about_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
209 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
210 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
211 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
212 |
{ 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
|
213 |
{ WIDGETS_END}, |
0 | 214 |
}; |
215 |
||
216 |
static const WindowDesc _about_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
217 |
WDP_CENTER, WDP_CENTER, 420, 272, 420, 272, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
218 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 219 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
220 |
_about_widgets, |
|
221 |
}; |
|
222 |
||
10645 | 223 |
struct AboutWindow : public Window { |
224 |
int scroll_height; |
|
225 |
uint16 counter; |
|
226 |
||
227 |
AboutWindow() : Window(&_about_desc) |
|
228 |
{ |
|
229 |
this->counter = 5; |
|
230 |
this->scroll_height = this->height - 40; |
|
231 |
this->FindWindowPlacementAndResize(&_about_desc); |
|
232 |
} |
|
233 |
||
234 |
virtual void OnPaint() |
|
235 |
{ |
|
236 |
static const char *credits[] = { |
|
237 |
/************************************************************************* |
|
238 |
* maximum length of string which fits in window -^*/ |
|
239 |
"Original design by Chris Sawyer", |
|
240 |
"Original graphics by Simon Foster", |
|
241 |
"", |
|
242 |
"The OpenTTD team (in alphabetical order):", |
|
243 |
" Jean-Francois Claeys (Belugas) - GUI, newindustries and more", |
|
244 |
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles", |
|
245 |
" Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework", |
|
246 |
" Loïc Guilloux (glx) - General coding", |
|
247 |
" Christoph Elsenhans (frosch) - General coding", |
|
248 |
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)", |
|
249 |
" Jonathan Coome (Maedhros) - High priest of the newGRF Temple", |
|
250 |
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host", |
|
251 |
" Owen Rudge (orudge) - Forum host, OS/2 port", |
|
252 |
" Peter Nelson (peter1138) - Spiritual descendant from newGRF gods", |
|
253 |
" Remko Bijker (Rubidium) - Lead coder and way more", |
|
254 |
" Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker", |
|
255 |
" Zdenek Sojka (SmatZ) - Bug finder and fixer", |
|
256 |
"", |
|
257 |
"Inactive Developers:", |
|
258 |
" Victor Fischer (Celestar) - Programming everywhere you need him to", |
|
259 |
" Tamás Faragó (Darkvater) - Ex-Lead coder", |
|
260 |
" Christoph Mallon (Tron) - Programmer, code correctness police", |
|
261 |
"", |
|
262 |
"Retired Developers:", |
|
263 |
" Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)", |
|
264 |
" Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)", |
|
265 |
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)", |
|
266 |
" Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)", |
|
267 |
"", |
|
268 |
"Special thanks go out to:", |
|
269 |
" Josef Drexler - For his great work on TTDPatch", |
|
270 |
" Marcin Grzegorczyk - For his documentation of TTD internals", |
|
271 |
" Petr Baudis (pasky) - Many patches, newGRF support", |
|
272 |
" Stefan Meißner (sign_de) - For his work on the console", |
|
273 |
" Simon Sasburg (HackyKid) - Many bugfixes he has blessed us with", |
|
274 |
" Cian Duffy (MYOB) - BeOS port / manual writing", |
|
275 |
" Christian Rosentreter (tokai) - MorphOS / AmigaOS port", |
|
276 |
" Richard Kempton (richK) - additional airports, initial TGP implementation", |
|
277 |
"", |
|
278 |
" Michael Blunck - Pre-Signals and Semaphores © 2003", |
|
279 |
" George - Canal/Lock graphics © 2003-2004", |
|
280 |
" David Dallaston - Tram tracks", |
|
281 |
" Marcin Grzegorczyk - Foundations for Tracks on Slopes", |
|
282 |
" All Translators - Who made OpenTTD a truly international game", |
|
283 |
" Bug Reporters - Without whom OpenTTD would still be full of bugs!", |
|
284 |
"", |
|
285 |
"", |
|
286 |
"And last but not least:", |
|
287 |
" Chris Sawyer - For an amazing game!" |
|
288 |
}; |
|
289 |
||
290 |
this->DrawWidgets(); |
|
291 |
||
292 |
/* Show original copyright and revision version */ |
|
293 |
DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, TC_FROMSTRING); |
|
294 |
DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING); |
|
295 |
||
296 |
int y = this->scroll_height; |
|
297 |
||
298 |
/* Show all scrolling credits */ |
|
299 |
for (uint i = 0; i < lengthof(credits); i++) { |
|
300 |
if (y >= 50 && y < (this->height - 40)) { |
|
301 |
DoDrawString(credits[i], 10, y, TC_BLACK); |
|
302 |
} |
|
303 |
y += 10; |
|
304 |
} |
|
305 |
||
306 |
/* If the last text has scrolled start a new from the start */ |
|
307 |
if (y < 50) this->scroll_height = this->height - 40; |
|
308 |
||
309 |
DoDrawStringCentered(210, this->height - 25, "Website: http://www.openttd.org", TC_BLACK); |
|
310 |
DrawStringCentered(210, this->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING); |
|
311 |
} |
|
312 |
||
313 |
virtual void OnTick() |
|
314 |
{ |
|
315 |
if (--this->counter == 0) { |
|
316 |
this->counter = 5; |
|
317 |
this->scroll_height--; |
|
318 |
this->SetDirty(); |
|
319 |
} |
|
320 |
} |
|
321 |
}; |
|
0 | 322 |
|
6573 | 323 |
void ShowAboutWindow() |
0 | 324 |
{ |
325 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
10645 | 326 |
new AboutWindow(); |
0 | 327 |
} |
328 |
||
329 |
static const Widget _errmsg_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
330 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
331 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
332 |
{ 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
|
333 |
{ WIDGETS_END}, |
0 | 334 |
}; |
335 |
||
336 |
static const Widget _errmsg_face_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
337 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
338 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
339 |
{ 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
|
340 |
{ WIDGETS_END}, |
0 | 341 |
}; |
342 |
||
10645 | 343 |
struct ErrmsgWindow : public Window { |
344 |
private: |
|
345 |
uint duration; |
|
346 |
uint64 decode_params[20]; |
|
347 |
StringID message_1; |
|
348 |
StringID message_2; |
|
349 |
bool show_player_face; |
|
0 | 350 |
|
10645 | 351 |
public: |
352 |
ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_player_face) : |
|
353 |
Window(pt.x, pt.y, width, height, WC_ERRMSG, widget), |
|
354 |
show_player_face(show_player_face) |
|
355 |
{ |
|
356 |
this->duration = _patches.errmsg_duration; |
|
357 |
CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params)); |
|
358 |
this->message_1 = msg1; |
|
359 |
this->message_2 = msg2; |
|
360 |
this->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
|
361 |
this->FindWindowPlacementAndResize(width, height); |
|
362 |
} |
|
2639 | 363 |
|
10645 | 364 |
virtual void OnPaint() |
365 |
{ |
|
366 |
static int y[][3] = { |
|
367 |
{15, 25, 30}, // _errmsg_widgets |
|
368 |
{45, 65, 90}, // _errmsg_face_widgets |
|
369 |
}; |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
370 |
|
10645 | 371 |
CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); |
372 |
this->DrawWidgets(); |
|
373 |
CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
374 |
|
10645 | 375 |
/* If the error message comes from a NewGRF, we must use the text ref. stack reserved for error messages. |
376 |
* 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 |
|
377 |
*/ |
|
378 |
SwitchToErrorRefStack(); |
|
379 |
RewindTextRefStack(); |
|
380 |
||
381 |
if (this->show_player_face) { |
|
382 |
const Player *p = GetPlayer((PlayerID)GetDParamX(this->decode_params, 2)); |
|
383 |
DrawPlayerFace(p->face, p->player_color, 2, 16); |
|
384 |
} |
|
385 |
||
386 |
byte j = (this->message_1 == INVALID_STRING_ID) ? 1 : 0; |
|
387 |
DrawStringMultiCenter(this->width - 120, y[this->show_player_face][j], this->message_2, this->width - 2); |
|
388 |
if (j == 0) { |
|
389 |
DrawStringMultiCenter(this->width - 120, y[this->show_player_face][2], this->message_1, this->width - 2); |
|
390 |
} |
|
391 |
||
392 |
/* Switch back to the normal text ref. stack for NewGRF texts */ |
|
393 |
SwitchToNormalRefStack(); |
|
0 | 394 |
} |
10645 | 395 |
|
396 |
virtual void OnMouseLoop() |
|
397 |
{ |
|
398 |
if (_right_button_down) delete this; |
|
399 |
} |
|
400 |
||
401 |
virtual void OnHundredthTick() |
|
402 |
{ |
|
403 |
if (--this->duration == 0) delete this; |
|
404 |
} |
|
405 |
||
406 |
~ErrmsgWindow() |
|
407 |
{ |
|
408 |
SetRedErrorSquare(0); |
|
409 |
extern StringID _switch_mode_errorstr; |
|
410 |
_switch_mode_errorstr = INVALID_STRING_ID; |
|
411 |
} |
|
412 |
||
413 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
|
414 |
{ |
|
415 |
if (keycode != WKC_SPACE) return ES_NOT_HANDLED; |
|
416 |
delete this; |
|
417 |
return ES_HANDLED; |
|
418 |
} |
|
419 |
}; |
|
0 | 420 |
|
421 |
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) |
|
422 |
{ |
|
423 |
DeleteWindowById(WC_ERRMSG, 0); |
|
424 |
||
10645 | 425 |
if (!_patches.errmsg_duration) return; |
0 | 426 |
|
10645 | 427 |
if (msg_2 == STR_NULL) msg_2 = STR_EMPTY; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
428 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
429 |
Point pt; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
430 |
const ViewPort *vp; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
431 |
|
10645 | 432 |
if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= 8) { |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
433 |
if ((x | y) != 0) { |
0 | 434 |
pt = RemapCoords2(x, y); |
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
435 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
0 | 436 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
437 |
/* move x pos to opposite corner */ |
9624 | 438 |
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left; |
0 | 439 |
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
|
440 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
441 |
/* move y pos to opposite corner */ |
9624 | 442 |
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; |
0 | 443 |
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
|
444 |
|
0 | 445 |
} else { |
446 |
pt.x = (_screen.width - 240) >> 1; |
|
447 |
pt.y = (_screen.height - 46) >> 1; |
|
448 |
} |
|
10645 | 449 |
new ErrmsgWindow(pt, 240, 46, msg_1, msg_2, _errmsg_widgets, false); |
0 | 450 |
} else { |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
451 |
if ((x | y) != 0) { |
0 | 452 |
pt = RemapCoords2(x, y); |
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5116
diff
changeset
|
453 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
454 |
pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
455 |
pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
0 | 456 |
} else { |
457 |
pt.x = (_screen.width - 334) >> 1; |
|
458 |
pt.y = (_screen.height - 137) >> 1; |
|
459 |
} |
|
10645 | 460 |
new ErrmsgWindow(pt, 334, 137, msg_1, msg_2, _errmsg_face_widgets, true); |
0 | 461 |
} |
462 |
} |
|
463 |
||
9629 | 464 |
void ShowEstimatedCostOrIncome(Money cost, int x, int y) |
0 | 465 |
{ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
466 |
StringID msg = STR_0805_ESTIMATED_COST; |
0 | 467 |
|
468 |
if (cost < 0) { |
|
469 |
cost = -cost; |
|
470 |
msg = STR_0807_ESTIMATED_INCOME; |
|
471 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
472 |
SetDParam(0, cost); |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2475
diff
changeset
|
473 |
ShowErrorMessage(INVALID_STRING_ID, msg, x, y); |
0 | 474 |
} |
475 |
||
9629 | 476 |
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost) |
0 | 477 |
{ |
478 |
Point pt = RemapCoords(x,y,z); |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
479 |
StringID msg = STR_0801_COST; |
0 | 480 |
|
481 |
if (cost < 0) { |
|
482 |
cost = -cost; |
|
483 |
msg = STR_0803_INCOME; |
|
484 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
485 |
SetDParam(0, cost); |
9629 | 486 |
AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING); |
0 | 487 |
} |
488 |
||
9629 | 489 |
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost) |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
490 |
{ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
491 |
Point pt = RemapCoords(x,y,z); |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
492 |
|
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
493 |
SetDParam(0, cost); |
9629 | 494 |
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING); |
495 |
} |
|
496 |
||
497 |
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string) |
|
498 |
{ |
|
499 |
Point pt = RemapCoords(x, y, z); |
|
500 |
||
501 |
assert(string != STR_NULL); |
|
502 |
||
503 |
SetDParam(0, percent); |
|
504 |
return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC); |
|
505 |
} |
|
506 |
||
507 |
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string) |
|
508 |
{ |
|
509 |
assert(string != STR_NULL); |
|
510 |
||
511 |
SetDParam(0, percent); |
|
512 |
UpdateTextEffect(te_id, string); |
|
513 |
} |
|
514 |
||
515 |
void HideFillingPercent(TextEffectID te_id) |
|
516 |
{ |
|
517 |
if (te_id != INVALID_TE_ID) RemoveTextEffect(te_id); |
|
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
518 |
} |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1914
diff
changeset
|
519 |
|
2275
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
520 |
static const Widget _tooltips_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
521 |
{ 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
|
522 |
{ WIDGETS_END}, |
0 | 523 |
}; |
524 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
525 |
struct TooltipsWindow : public Window |
0 | 526 |
{ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
527 |
StringID string_id; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
528 |
byte paramcount; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
529 |
uint64 params[5]; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
530 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
531 |
TooltipsWindow(int x, int y, int width, int height, const Widget *widget, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
532 |
StringID str, uint paramcount, const uint64 params[]) : |
10645 | 533 |
Window(x, y, width, height, WC_TOOLTIPS, widget) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
534 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
535 |
this->string_id = str; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
536 |
assert(sizeof(this->params[0]) == sizeof(params[0])); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
537 |
memcpy(this->params, params, sizeof(this->params[0]) * paramcount); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
538 |
this->paramcount = paramcount; |
0 | 539 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
540 |
this->flags4 &= ~WF_WHITE_BORDER_MASK; // remove white-border from tooltip |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
541 |
this->widget[0].right = width; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
542 |
this->widget[0].bottom = height; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
543 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
544 |
FindWindowPlacementAndResize(width, height); |
0 | 545 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
546 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
547 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
548 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
549 |
GfxFillRect(0, 0, this->width - 1, this->height - 1, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
550 |
GfxFillRect(1, 1, this->width - 2, this->height - 2, 0x44); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
551 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
552 |
for (uint arg = 0; arg < this->paramcount; arg++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
553 |
SetDParam(arg, this->params[arg]); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
554 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
555 |
DrawStringMultiCenter((this->width >> 1), (this->height >> 1) - 5, this->string_id, this->width - 2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
556 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
557 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
558 |
virtual void OnMouseLoop() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
559 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
560 |
/* We can show tooltips while dragging tools. These are shown as long as |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
561 |
* we are dragging the tool. Normal tooltips work with rmb */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
562 |
if (this->paramcount == 0 ) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
563 |
if (!_right_button_down) delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
564 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
565 |
if (!_left_button_down) delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
566 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
567 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
568 |
}; |
0 | 569 |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
570 |
/** Shows a tooltip |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
571 |
* @param str String to be displayed |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
572 |
* @param paramcount number of params to deal with |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
573 |
* @param params (optional) up to 5 pieces of additional information that may be |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
574 |
* added to a tooltip; currently only supports parameters of {NUM} (integer) */ |
9629 | 575 |
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]) |
0 | 576 |
{ |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
577 |
DeleteWindowById(WC_TOOLTIPS, 0); |
0 | 578 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
579 |
/* We only show measurement tooltips with patch setting on */ |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4850
diff
changeset
|
580 |
if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return; |
0 | 581 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
582 |
for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
583 |
char buffer[512]; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4909
diff
changeset
|
584 |
GetString(buffer, str, lastof(buffer)); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
585 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
586 |
Dimension br = GetStringBoundingBox(buffer); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
587 |
br.width += 6; br.height += 4; // increase slightly to have some space around the box |
0 | 588 |
|
4558
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
589 |
/* Cut tooltip length to 200 pixels max, wrap to new line if longer */ |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
590 |
if (br.width > 200) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
591 |
br.height += ((br.width - 4) / 176) * 10; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
592 |
br.width = 200; |
0 | 593 |
} |
594 |
||
4558
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
595 |
/* Correctly position the tooltip position, watch out for window and cursor size |
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
596 |
* Clamp value to below main toolbar and above statusbar. If tooltip would |
657e73957b4b
(svn r6405) -Codechange: When showing tooltips, properly position the tooltip, considering
Darkvater
parents:
4416
diff
changeset
|
597 |
* go below window, flip it so it is shown above the cursor */ |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
598 |
int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4719
diff
changeset
|
599 |
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
600 |
int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); |
0 | 601 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
602 |
new TooltipsWindow(x, y, br.width, br.height, _tooltips_widgets, str, paramcount, params); |
0 | 603 |
} |
604 |
||
605 |
||
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
606 |
static int DrawStationCoverageText(const AcceptedCargo cargo, |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
607 |
int str_x, int str_y, StationCoverageType sct, bool supplies) |
0 | 608 |
{ |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
609 |
bool first = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
610 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
611 |
char *b = InlineString(_userstring, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS); |
0 | 612 |
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
613 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
614 |
if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
615 |
switch (sct) { |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
616 |
case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
617 |
case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
618 |
case SCT_ALL: break; |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
619 |
default: NOT_REACHED(); |
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
620 |
} |
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
9869
diff
changeset
|
621 |
if (cargo[i] >= (supplies ? 1U : 8U)) { |
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
622 |
if (first) { |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
623 |
first = false; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
624 |
} else { |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
625 |
/* Add a comma if this is not the first item */ |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
626 |
*b++ = ','; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
627 |
*b++ = ' '; |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
628 |
} |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6144
diff
changeset
|
629 |
b = InlineString(b, GetCargo(i)->name); |
0 | 630 |
} |
631 |
} |
|
632 |
||
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
633 |
/* If first is still true then no cargo is accepted */ |
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
634 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
0 | 635 |
|
5038
cd0a32afb616
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
636 |
*b = '\0'; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
637 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
638 |
/* Make sure we detect any buffer overflow */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
639 |
assert(b < endof(_userstring)); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
640 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
641 |
return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
0 | 642 |
} |
643 |
||
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
644 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
645 |
* Calculates and draws the accepted or supplied cargo around the selected tile(s) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
646 |
* @param sx x position where the string is to be drawn |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
647 |
* @param sy y position where the string is to be drawn |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
648 |
* @param sct which type of cargo is to be displayed (passengers/non-passengers) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
649 |
* @param rad radius around selected tile(s) to be searched |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
650 |
* @param supplies if supplied cargos should be drawn, else accepted cargos |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
651 |
* @return Returns the y value below the string that was drawn |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
652 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
653 |
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies) |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
654 |
{ |
2873 | 655 |
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
656 |
AcceptedCargo cargo; |
2873 | 657 |
if (tile < MapSize()) { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
658 |
if (supplies) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
659 |
GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
660 |
} else { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
661 |
GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
662 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
663 |
return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies); |
0 | 664 |
} |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
665 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
666 |
return sy; |
0 | 667 |
} |
668 |
||
4171 | 669 |
void CheckRedrawStationCoverage(const Window *w) |
0 | 670 |
{ |
2549 | 671 |
if (_thd.dirty & 1) { |
672 |
_thd.dirty &= ~1; |
|
0 | 673 |
SetWindowDirty(w); |
674 |
} |
|
675 |
} |
|
676 |
||
677 |
void SetVScrollCount(Window *w, int num) |
|
678 |
{ |
|
679 |
w->vscroll.count = num; |
|
680 |
num -= w->vscroll.cap; |
|
681 |
if (num < 0) num = 0; |
|
682 |
if (num < w->vscroll.pos) w->vscroll.pos = num; |
|
683 |
} |
|
684 |
||
842 | 685 |
void SetVScroll2Count(Window *w, int num) |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
686 |
{ |
842 | 687 |
w->vscroll2.count = num; |
688 |
num -= w->vscroll2.cap; |
|
689 |
if (num < 0) num = 0; |
|
690 |
if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
|
691 |
} |
|
692 |
||
0 | 693 |
void SetHScrollCount(Window *w, int num) |
694 |
{ |
|
695 |
w->hscroll.count = num; |
|
696 |
num -= w->hscroll.cap; |
|
697 |
if (num < 0) num = 0; |
|
698 |
if (num < w->hscroll.pos) w->hscroll.pos = num; |
|
699 |
} |
|
700 |
||
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
701 |
/* Delete a character at the caret position in a text buf. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
702 |
* If backspace is set, delete the character before the caret, |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
703 |
* else delete the character after it. */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
704 |
static void DelChar(Textbuf *tb, bool backspace) |
911
bde79514283f
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
705 |
{ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
706 |
WChar c; |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
707 |
char *s = tb->buf + tb->caretpos; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
708 |
|
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
709 |
if (backspace) s = Utf8PrevChar(s); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
710 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
711 |
size_t len = Utf8Decode(&c, s); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
712 |
uint width = GetCharacterWidth(FS_NORMAL, c); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
713 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
714 |
tb->width -= width; |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
715 |
if (backspace) { |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
716 |
tb->caretpos -= len; |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
717 |
tb->caretxoffs -= width; |
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
718 |
} |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
719 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
720 |
/* Move the remaining characters over the marker */ |
6540
4db000b2cc41
(svn r9011) -Codechange (r9003): Rework Utf8PrevChar so that it returns a pointer to the previous UTF8 character's first byte instead of a byte-length offset
Darkvater
parents:
6537
diff
changeset
|
721 |
memmove(s, s + len, tb->length - (s - tb->buf) - len + 1); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
722 |
tb->length -= len; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
723 |
} |
911
bde79514283f
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
724 |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
725 |
/** |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
726 |
* Delete a character from a textbuffer, either with 'Delete' or 'Backspace' |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
727 |
* The character is delete from the position the caret is at |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
728 |
* @param tb Textbuf type to be changed |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
729 |
* @param delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
730 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
731 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
732 |
bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
733 |
{ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
734 |
if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
735 |
DelChar(tb, true); |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
736 |
return true; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
737 |
} else if (delmode == WKC_DELETE && tb->caretpos < tb->length) { |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
738 |
DelChar(tb, false); |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
739 |
return true; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
740 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
741 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
742 |
return false; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
743 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
744 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
745 |
/** |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
746 |
* Delete every character in the textbuffer |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
747 |
* @param tb Textbuf buffer to be emptied |
1879
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
748 |
*/ |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
749 |
void DeleteTextBufferAll(Textbuf *tb) |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
750 |
{ |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
751 |
memset(tb->buf, 0, tb->maxlength); |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
752 |
tb->length = tb->width = 0; |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
753 |
tb->caretpos = tb->caretxoffs = 0; |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
754 |
} |
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
755 |
|
2ccc61e922e2
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Darkvater
parents:
1860
diff
changeset
|
756 |
/** |
3459
b78229520bcf
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
757 |
* Insert a character to a textbuffer. If maxwidth of the Textbuf is zero, |
b78229520bcf
(svn r4302) - Fix: s/maxlength/maxwidth of course, the buffer size is always set. Comment-change only
Darkvater
parents:
3458
diff
changeset
|
758 |
* we don't care about the visual-length but only about the physical |
3458
d3a6ddfa6784
(svn r4301) - Fix: the maxlength parameter of Textbuf is supposed to be the size of the buffer (so length of string + '\0'), but in the code it was a mix of both. It didn't cause any problems though, only an occasionaly one-less character than allowed. (thanks Tron for noticing)
Darkvater
parents:
3421
diff
changeset
|
759 |
* length of the string |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
760 |
* @param tb Textbuf type to be changed |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
761 |
* @param key Character to be inserted |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
762 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
763 |
*/ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
764 |
bool InsertTextBufferChar(Textbuf *tb, WChar key) |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
765 |
{ |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3719
diff
changeset
|
766 |
const byte charwidth = GetCharacterWidth(FS_NORMAL, key); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
767 |
size_t len = Utf8CharLen(key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
768 |
if (tb->length < (tb->maxlength - len) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
769 |
memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
770 |
Utf8Encode(tb->buf + tb->caretpos, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
771 |
tb->length += len; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
772 |
tb->width += charwidth; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
773 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
774 |
tb->caretpos += len; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
775 |
tb->caretxoffs += charwidth; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
776 |
return true; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
777 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
778 |
return false; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
779 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
780 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
781 |
/** |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
782 |
* Handle text navigation with arrow keys left/right. |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
783 |
* This defines where the caret will blink and the next characer interaction will occur |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
784 |
* @param tb Textbuf type where navigation occurs |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
785 |
* @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
786 |
* @return Return true on successful change of Textbuf, or false otherwise |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
787 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
788 |
bool MoveTextBufferPos(Textbuf *tb, int navmode) |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
789 |
{ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
790 |
switch (navmode) { |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
791 |
case WKC_LEFT: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
792 |
if (tb->caretpos != 0) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
793 |
WChar c; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
794 |
const char *s = Utf8PrevChar(tb->buf + tb->caretpos); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
795 |
Utf8Decode(&c, s); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
796 |
tb->caretpos = s - tb->buf; // -= (tb->buf + tb->caretpos - s) |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
797 |
tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
798 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
799 |
return true; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
800 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
801 |
break; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
802 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
803 |
case WKC_RIGHT: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
804 |
if (tb->caretpos < tb->length) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
805 |
WChar c; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
806 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
807 |
tb->caretpos += Utf8Decode(&c, tb->buf + tb->caretpos); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
808 |
tb->caretxoffs += GetCharacterWidth(FS_NORMAL, c); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
809 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
810 |
return true; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
811 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
812 |
break; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
813 |
|
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
814 |
case WKC_HOME: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
815 |
tb->caretpos = 0; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
816 |
tb->caretxoffs = 0; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
817 |
return true; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
818 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
819 |
case WKC_END: |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
820 |
tb->caretpos = tb->length; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
821 |
tb->caretxoffs = tb->width; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
822 |
return true; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
823 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
824 |
default: |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
825 |
break; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
826 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
827 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
828 |
return false; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
829 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
830 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
831 |
/** |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
832 |
* Initialize the textbuffer by supplying it the buffer to write into |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
833 |
* and the maximum length of this buffer |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
834 |
* @param tb Textbuf type which is getting initialized |
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
835 |
* @param buf the buffer that will be holding the data for input |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
836 |
* @param maxlength maximum length in characters of this buffer |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
837 |
* @param maxwidth maximum length in pixels of this buffer. If reached, buffer |
4958 | 838 |
* cannot grow, even if maxlength would allow because there is space. A length |
839 |
* of zero '0' means the buffer is only restricted by maxlength */ |
|
4948
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
840 |
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth) |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
841 |
{ |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
842 |
tb->buf = (char*)buf; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
843 |
tb->maxlength = maxlength; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
844 |
tb->maxwidth = maxwidth; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
845 |
tb->caret = true; |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
846 |
UpdateTextBufferSize(tb); |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
847 |
} |
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
848 |
|
91dae24f3690
(svn r6937) -Codechange: Add an InitializeTextBuffer() function that handles setting up the
Darkvater
parents:
4939
diff
changeset
|
849 |
/** |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
850 |
* Update Textbuf type with its actual physical character and screenlength |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
851 |
* Get the count of characters in the string as well as the width in pixels. |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
852 |
* Useful when copying in a larger amount of text at once |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
853 |
* @param tb Textbuf type which length is calculated |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
854 |
*/ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
855 |
void UpdateTextBufferSize(Textbuf *tb) |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
856 |
{ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
857 |
const char *buf = tb->buf; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
858 |
WChar c = Utf8Consume(&buf); |
2630 | 859 |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
860 |
tb->width = 0; |
5698
6697ee90a195
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5682
diff
changeset
|
861 |
tb->length = 0; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
862 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
863 |
for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5079
diff
changeset
|
864 |
tb->width += GetCharacterWidth(FS_NORMAL, c); |
5698
6697ee90a195
(svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI.
rubidium
parents:
5682
diff
changeset
|
865 |
tb->length += Utf8CharLen(c); |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
866 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
867 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
868 |
tb->caretpos = tb->length; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
869 |
tb->caretxoffs = tb->width; |
911
bde79514283f
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
870 |
} |
bde79514283f
(svn r1398) -Feature: CTRL+V (Paste) now works on all editboxes. This includes 'Add Server', chat, etc. Feature is Windows only.
darkvater
parents:
910
diff
changeset
|
871 |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
872 |
bool HandleCaret(Textbuf *tb) |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
873 |
{ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
874 |
/* caret changed? */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
875 |
bool b = !!(_caret_timer & 0x20); |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
876 |
|
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
877 |
if (b != tb->caret) { |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
878 |
tb->caret = b; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
879 |
return true; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
880 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
881 |
return false; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
882 |
} |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
883 |
|
10645 | 884 |
int QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key, uint16 keycode, Window::EventState &state) |
0 | 885 |
{ |
10645 | 886 |
state = Window::ES_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
887 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
888 |
switch (keycode) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
889 |
case WKC_ESC: return 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
890 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
891 |
case WKC_RETURN: case WKC_NUM_ENTER: return 1; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
892 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
893 |
case (WKC_CTRL | 'V'): |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
894 |
if (InsertTextBufferClipboard(&this->text)) w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
895 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
896 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
897 |
case (WKC_CTRL | 'U'): |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
898 |
DeleteTextBufferAll(&this->text); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
899 |
w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
900 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
901 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
902 |
case WKC_BACKSPACE: case WKC_DELETE: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
903 |
if (DeleteTextBufferChar(&this->text, keycode)) w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
904 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
905 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
906 |
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
907 |
if (MoveTextBufferPos(&this->text, keycode)) w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
908 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
909 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
910 |
default: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
911 |
if (IsValidChar(key, this->afilter)) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
912 |
if (InsertTextBufferChar(&this->text, key)) w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
913 |
} else { // key wasn't caught. Continue only if standard entry specified |
10645 | 914 |
state = (this->afilter == CS_ALPHANUMERAL) ? Window::ES_HANDLED : Window::ES_NOT_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
915 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
916 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
917 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
918 |
return 0; |
0 | 919 |
} |
920 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
921 |
void QueryString::HandleEditBox(Window *w, int wid) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
922 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
923 |
if (HandleCaret(&this->text)) w->InvalidateWidget(wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
924 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
925 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
926 |
void QueryString::DrawEditBox(Window *w, int wid) |
0 | 927 |
{ |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
928 |
const Widget *wi = &w->widget[wid]; |
0 | 929 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
930 |
assert((wi->type & WWT_MASK) == WWT_EDITBOX); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
931 |
|
5890
45bd89352147
(svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents:
5847
diff
changeset
|
932 |
GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215); |
45bd89352147
(svn r8098) -Fix (r6964): For editboxen, always fill the background with black, and not only after a valid call to FillDrawPixelInfo. This solves some graphics glitches with background widget-colour showing through on frequent redraws.
Darkvater
parents:
5847
diff
changeset
|
933 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
934 |
DrawPixelInfo dpi; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
935 |
int delta; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
936 |
|
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
937 |
/* Limit the drawing of the string inside the widget boundaries */ |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
938 |
if (!FillDrawPixelInfo(&dpi, |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
939 |
wi->left + 4, |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
940 |
wi->top + 1, |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
941 |
wi->right - wi->left - 4, |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
942 |
wi->bottom - wi->top - 1)) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
943 |
return; |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
944 |
} |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
945 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
946 |
DrawPixelInfo *old_dpi = _cur_dpi; |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
947 |
_cur_dpi = &dpi; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
948 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
949 |
/* We will take the current widget length as maximum width, with a small |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
950 |
* space reserved at the end for the caret to show */ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
951 |
const Textbuf *tb = &this->text; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
952 |
|
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
953 |
delta = (wi->right - wi->left) - tb->width - 10; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
954 |
if (delta > 0) delta = 0; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
955 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
956 |
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs; |
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
957 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
958 |
DoDrawString(tb->buf, delta, 0, TC_YELLOW); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
959 |
if (tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE); |
4955
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
960 |
|
e3496ee0e37d
(svn r6954) -Feature: Constrain the drawing of a string inside an editbox to the dimensions of
Darkvater
parents:
4949
diff
changeset
|
961 |
_cur_dpi = old_dpi; |
0 | 962 |
} |
963 |
||
10645 | 964 |
int QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
965 |
{ |
10645 | 966 |
return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
967 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
968 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
969 |
void QueryStringBaseWindow::HandleEditBox(int wid) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
970 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
971 |
this->QueryString::HandleEditBox(this, wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
972 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
973 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
974 |
void QueryStringBaseWindow::DrawEditBox(int wid) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
975 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
976 |
this->QueryString::DrawEditBox(this, wid); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
977 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
978 |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
979 |
enum QueryStringWidgets { |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
980 |
QUERY_STR_WIDGET_TEXT = 3, |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
981 |
QUERY_STR_WIDGET_CANCEL, |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
982 |
QUERY_STR_WIDGET_OK |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
983 |
}; |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
984 |
|
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
985 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
986 |
struct QueryStringWindow : public QueryStringBaseWindow |
0 | 987 |
{ |
10645 | 988 |
QueryStringWindow(const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(desc) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
989 |
{ |
10645 | 990 |
this->parent = parent; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
991 |
SetBit(_no_scroll, SCROLL_EDIT); |
0 | 992 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
993 |
this->FindWindowPlacementAndResize(desc); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
994 |
} |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
995 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
996 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
997 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
998 |
SetDParam(0, this->caption); |
10645 | 999 |
this->DrawWidgets(); |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1000 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1001 |
this->DrawEditBox(QUERY_STR_WIDGET_TEXT); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1002 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1003 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1004 |
void OnOk() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1005 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1006 |
if (this->orig == NULL || strcmp(this->text.buf, this->orig) != 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1007 |
/* If the parent is NULL, the editbox is handled by general function |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1008 |
* HandleOnEditText */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1009 |
if (this->parent != NULL) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1010 |
this->parent->OnQueryTextFinished(this->text.buf); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1011 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1012 |
HandleOnEditText(this->text.buf); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1013 |
} |
10645 | 1014 |
this->handled = true; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1015 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1016 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1017 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1018 |
virtual void OnClick(Point pt, int widget) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1019 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1020 |
switch (widget) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1021 |
case QUERY_STR_WIDGET_TEXT: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1022 |
ShowOnScreenKeyboard(this, QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1023 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1024 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1025 |
case QUERY_STR_WIDGET_OK: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1026 |
this->OnOk(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1027 |
/* Fallthrough */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1028 |
case QUERY_STR_WIDGET_CANCEL: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1029 |
delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1030 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1031 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1032 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1033 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1034 |
virtual void OnMouseLoop() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1035 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1036 |
this->HandleEditBox(QUERY_STR_WIDGET_TEXT); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1037 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1038 |
|
10645 | 1039 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1040 |
{ |
10645 | 1041 |
EventState state; |
1042 |
switch (this->HandleEditBoxKey(QUERY_STR_WIDGET_TEXT, key, keycode, state)) { |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1043 |
case 1: this->OnOk(); // Enter pressed, confirms change |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1044 |
/* FALL THROUGH */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1045 |
case 2: delete this; break; // ESC pressed, closes window, abandons changes |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1046 |
} |
10645 | 1047 |
return state; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1048 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1049 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1050 |
~QueryStringWindow() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1051 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1052 |
if (!this->handled && this->parent != NULL) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1053 |
this->handled = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1054 |
this->parent->OnQueryTextFinished(NULL); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1055 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1056 |
ClrBit(_no_scroll, SCROLL_EDIT); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1057 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1058 |
}; |
0 | 1059 |
|
1060 |
static const Widget _query_string_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1061 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1062 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1063 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1064 |
{ WWT_EDITBOX, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1065 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
1066 |
{ 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
|
1067 |
{ WIDGETS_END}, |
0 | 1068 |
}; |
1069 |
||
1070 |
static const WindowDesc _query_string_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1071 |
190, 219, 260, 42, 260, 42, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1072 |
WC_QUERY_STRING, WC_NONE, |
0 | 1073 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1074 |
_query_string_widgets, |
|
1075 |
}; |
|
1076 |
||
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1077 |
/** Show a query popup window with a textbox in it. |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1078 |
* @param str StringID for the text shown in the textbox |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1079 |
* @param caption StringID of text shown in caption of querywindow |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1080 |
* @param maxlen maximum length in characters allowed. If bit 12 is set we |
10645 | 1081 |
* will not check the resulting string against to original string to return success |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1082 |
* @param maxwidth maximum width in pixels allowed |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1083 |
* @param parent pointer to a Window that will handle the events (ok/cancel) of this |
10645 | 1084 |
* window. If NULL, results are handled by global function HandleOnEditText |
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1085 |
* @param afilter filters out unwanted character input */ |
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5680
diff
changeset
|
1086 |
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter) |
0 | 1087 |
{ |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
1088 |
uint realmaxlen = maxlen & ~0x1000; |
0 | 1089 |
|
1090 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1091 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1092 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1093 |
QueryStringWindow *w = new QueryStringWindow(&_query_string_desc, parent); |
1386
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents:
1363
diff
changeset
|
1094 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1095 |
assert(realmaxlen < lengthof(w->edit_str_buf)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1096 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1097 |
GetString(w->edit_str_buf, str, lastof(w->edit_str_buf)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1098 |
w->edit_str_buf[realmaxlen - 1] = '\0'; |
596
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1099 |
|
e876d7319634
(svn r1018) -Fix: Buffer overflow in edit box, because we misuse maxlen for a flag..
truelight
parents:
568
diff
changeset
|
1100 |
if (maxlen & 0x1000) { |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1101 |
w->orig = NULL; |
1386
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents:
1363
diff
changeset
|
1102 |
} else { |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1103 |
strecpy(w->orig_str_buf, w->edit_str_buf, lastof(w->orig_str_buf)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1104 |
w->orig = w->orig_str_buf; |
1386
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents:
1363
diff
changeset
|
1105 |
} |
0 | 1106 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1107 |
w->LowerWidget(QUERY_STR_WIDGET_TEXT); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1108 |
w->caption = caption; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1109 |
w->afilter = afilter; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1110 |
InitializeTextBuffer(&w->text, w->edit_str_buf, realmaxlen, maxwidth); |
0 | 1111 |
} |
1112 |
||
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1113 |
|
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1114 |
enum QueryWidgets { |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1115 |
QUERY_WIDGET_CAPTION = 1, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1116 |
QUERY_WIDGET_NO = 3, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1117 |
QUERY_WIDGET_YES |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1118 |
}; |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1119 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1120 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1121 |
* Window used for asking the user a YES/NO question. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1122 |
*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1123 |
struct QueryWindow : public Window { |
5724
e6633aa2c817
(svn r7757) -Fix (r7621): x64 did not compile because query_d was too big. Reorder the elements
Darkvater
parents:
5720
diff
changeset
|
1124 |
void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise |
9629 | 1125 |
uint64 params[10]; ///< local copy of _decode_parameters |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1126 |
StringID message; ///< message shown for query window |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1127 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1128 |
QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) : Window(desc) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1129 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1130 |
if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1131 |
this->parent = parent; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1132 |
this->left = parent->left + (parent->width / 2) - (this->width / 2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1133 |
this->top = parent->top + (parent->height / 2) - (this->height / 2); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1134 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1135 |
/* Create a backup of the variadic arguments to strings because it will be |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1136 |
* overridden pretty often. We will copy these back for drawing */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1137 |
CopyOutDParam(this->params, 0, lengthof(this->params)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1138 |
this->widget[QUERY_WIDGET_CAPTION].data = caption; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1139 |
this->message = message; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1140 |
this->proc = callback; |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1141 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1142 |
this->FindWindowPlacementAndResize(desc); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1143 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1144 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1145 |
~QueryWindow() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1146 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1147 |
if (this->proc != NULL) this->proc(this->parent, false); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1148 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1149 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1150 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1151 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1152 |
CopyInDParam(0, this->params, lengthof(this->params)); |
10645 | 1153 |
this->DrawWidgets(); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1154 |
CopyInDParam(0, this->params, lengthof(this->params)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1155 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1156 |
DrawStringMultiCenter(this->width / 2, (this->height / 2) - 10, this->message, this->width - 2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1157 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1158 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1159 |
virtual void OnClick(Point pt, int widget) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1160 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1161 |
switch (widget) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1162 |
case QUERY_WIDGET_YES: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1163 |
if (this->proc != NULL) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1164 |
this->proc(this->parent, true); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1165 |
this->proc = NULL; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1166 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1167 |
/* Fallthrough */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1168 |
case QUERY_WIDGET_NO: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1169 |
delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1170 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1171 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1172 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1173 |
|
10645 | 1174 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1175 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1176 |
/* ESC closes the window, Enter confirms the action */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1177 |
switch (keycode) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1178 |
case WKC_RETURN: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1179 |
case WKC_NUM_ENTER: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1180 |
if (this->proc != NULL) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1181 |
this->proc(this->parent, true); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1182 |
this->proc = NULL; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1183 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1184 |
/* Fallthrough */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1185 |
case WKC_ESC: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1186 |
delete this; |
10645 | 1187 |
return ES_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1188 |
} |
10645 | 1189 |
return ES_NOT_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1190 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1191 |
}; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1192 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1193 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1194 |
static const Widget _query_widgets[] = { |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1195 |
{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1196 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 209, 0, 13, STR_NULL, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1197 |
{ WWT_PANEL, RESIZE_NONE, 4, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1198 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 20, 90, 62, 73, STR_00C9_NO, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1199 |
{WWT_PUSHTXTBTN, RESIZE_NONE, 3, 120, 190, 62, 73, STR_00C8_YES, STR_NULL}, |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1200 |
{ WIDGETS_END }, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1201 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1202 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1203 |
static const WindowDesc _query_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1204 |
WDP_CENTER, WDP_CENTER, 210, 82, 210, 82, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1205 |
WC_CONFIRM_POPUP_QUERY, WC_NONE, |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1206 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_DEF_WIDGET | WDF_MODAL, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1207 |
_query_widgets, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1208 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1209 |
|
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1210 |
/** Show a modal confirmation window with standard 'yes' and 'no' buttons |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1211 |
* The window is aligned to the centre of its parent. |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1212 |
* NOTE: You cannot use BindCString as parameter for this window! |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1213 |
* @param caption string shown as window caption |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1214 |
* @param message string that will be shown for the window |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1215 |
* @param parent pointer to parent window, if this pointer is NULL the parent becomes |
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1216 |
* the main window WC_MAIN_WINDOW |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
1217 |
* @param callback callback function pointer to set in the window descriptor*/ |
5669
ea25407ffa55
(svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents:
5568
diff
changeset
|
1218 |
void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1219 |
{ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1220 |
new QueryWindow(&_query_desc, caption, message, parent, callback); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1221 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1222 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1223 |
|
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1224 |
static const Widget _load_dialog_widgets[] = { |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1225 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1226 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1227 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1228 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1229 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1230 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 153, 0x0, STR_NULL}, |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1231 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1232 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 151, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1233 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 141, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1234 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 142, 153, 0x0, STR_RESIZE_BUTTON}, |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1235 |
{ WIDGETS_END}, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1236 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1237 |
|
0 | 1238 |
static const Widget _save_dialog_widgets[] = { |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1239 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1240 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1241 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1242 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1243 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1244 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 256, 48, 151, 0x0, STR_NULL}, |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1245 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 245, 256, 48, 59, SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1246 |
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 150, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1247 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 151, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1248 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 256, 152, 167, 0x0, STR_NULL}, |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
1249 |
{ WWT_EDITBOX, RESIZE_RTB, 14, 2, 254, 154, 165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1250 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 127, 168, 179, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1251 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 128, 244, 168, 179, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1252 |
{ 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
|
1253 |
{ WIDGETS_END}, |
0 | 1254 |
}; |
1255 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6523
diff
changeset
|
1256 |
/* Colors for fios types */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1257 |
const TextColour _fios_colors[] = { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1258 |
TC_LIGHT_BLUE, TC_DARK_GREEN, TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1259 |
TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1260 |
}; |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2255
diff
changeset
|
1261 |
|
6573 | 1262 |
void BuildFileList() |
0 | 1263 |
{ |
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1264 |
_fios_path_changed = true; |
0 | 1265 |
FiosFreeSavegameList(); |
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1266 |
|
2549 | 1267 |
switch (_saveload_mode) { |
1268 |
case SLD_NEW_GAME: |
|
1269 |
case SLD_LOAD_SCENARIO: |
|
1270 |
case SLD_SAVE_SCENARIO: |
|
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1271 |
_fios_list = FiosGetScenarioList(_saveload_mode); break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1272 |
case SLD_LOAD_HEIGHTMAP: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1273 |
_fios_list = FiosGetHeightmapList(_saveload_mode); break; |
2549 | 1274 |
|
4223
0f9535dda7ed
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4217
diff
changeset
|
1275 |
default: _fios_list = FiosGetSavegameList(_saveload_mode); break; |
2549 | 1276 |
} |
0 | 1277 |
} |
1278 |
||
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1279 |
static void DrawFiosTexts(uint maxw) |
0 | 1280 |
{ |
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1281 |
static const char *path = NULL; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1282 |
static StringID str = STR_4006_UNABLE_TO_READ_DRIVE; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1283 |
static uint32 tot = 0; |
0 | 1284 |
|
1596
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1285 |
if (_fios_path_changed) { |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1286 |
str = FiosGetDescText(&path, &tot); |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1287 |
_fios_path_changed = false; |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1288 |
} |
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1289 |
|
c1c439a2d5b2
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
darkvater
parents:
1594
diff
changeset
|
1290 |
if (str != STR_4006_UNABLE_TO_READ_DRIVE) SetDParam(0, tot); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1291 |
DrawString(2, 37, str, TC_FROMSTRING); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1292 |
DoDrawStringTruncated(path, 2, 27, TC_BLACK, maxw); |
0 | 1293 |
} |
1294 |
||
6573 | 1295 |
static void MakeSortedSaveGameList() |
0 | 1296 |
{ |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1297 |
uint sort_start = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1298 |
uint sort_end = 0; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1299 |
|
4171 | 1300 |
/* Directories are always above the files (FIOS_TYPE_DIR) |
1301 |
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE) |
|
1302 |
* Only sort savegames/scenarios, not directories |
|
0 | 1303 |
*/ |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1304 |
for (int i = 0; i < _fios_num; i++) { |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1305 |
switch (_fios_list[i].type) { |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1306 |
case FIOS_TYPE_DIR: sort_start++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1307 |
case FIOS_TYPE_PARENT: sort_start++; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1308 |
case FIOS_TYPE_DRIVE: sort_end++; break; |
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
10249
diff
changeset
|
1309 |
default: break; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
1310 |
} |
0 | 1311 |
} |
1312 |
||
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1313 |
uint s_amount = _fios_num - sort_start - sort_end; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1314 |
if (s_amount > 0) { |
0 | 1315 |
qsort(_fios_list + sort_start, s_amount, sizeof(FiosItem), compare_FiosItems); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1316 |
} |
0 | 1317 |
} |
1318 |
||
6573 | 1319 |
extern void StartupEngines(); |
1131
21a18a6c1b4b
(svn r1632) -Fix: [1108008] Scenario creation bug; engines are of correct year when scenario is saved
darkvater
parents:
1126
diff
changeset
|
1320 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1321 |
struct SaveLoadWindow : public QueryStringBaseWindow { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1322 |
FiosItem o_dir; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3890
diff
changeset
|
1323 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1324 |
void GenerateFileName() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1325 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1326 |
/* Check if we are not a spectator who wants to generate a name.. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1327 |
Let's use the name of player #0 for now. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1328 |
const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST); |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2070
diff
changeset
|
1329 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1330 |
SetDParam(0, p->index); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1331 |
SetDParam(1, _date); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1332 |
GetString(this->edit_str_buf, STR_4004, lastof(this->edit_str_buf)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1333 |
SanitizeFilename(this->edit_str_buf); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1334 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1335 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1336 |
SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(desc) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1337 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1338 |
static const StringID saveload_captions[] = { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1339 |
STR_4001_LOAD_GAME, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1340 |
STR_0298_LOAD_SCENARIO, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1341 |
STR_4000_SAVE_GAME, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1342 |
STR_0299_SAVE_SCENARIO, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1343 |
STR_LOAD_HEIGHTMAP, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1344 |
}; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1345 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1346 |
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1347 |
SetBit(_no_scroll, SCROLL_SAVE); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1348 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1349 |
/* Use an array to define what will be the current file type being handled |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1350 |
* by current file mode */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1351 |
switch (mode) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1352 |
case SLD_SAVE_GAME: this->GenerateFileName(); break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1353 |
case SLD_SAVE_SCENARIO: strcpy(this->edit_str_buf, "UNNAMED"); break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1354 |
default: break; |
0 | 1355 |
} |
2559
08e648022cb0
(svn r3096) - Feature: 'HOME' icon to saveload dialogs that jumps to the default save/load directory based on the dialog (added icon to openttd.grf, introduced FIOS_TYPE_DIRECT that allows arbitrary directory jumping).
Darkvater
parents:
2549
diff
changeset
|
1356 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1357 |
assert((uint)mode < lengthof(saveload_captions)); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1358 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1359 |
this->widget[1].data = saveload_captions[mode]; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1360 |
this->LowerWidget(7); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1361 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1362 |
this->afilter = CS_ALPHANUMERAL; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1363 |
InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 240); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1364 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1365 |
/* pause is only used in single-player, non-editor mode, non-menu mode. It |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1366 |
* will be unpaused in the WE_DESTROY event handler. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1367 |
if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1368 |
if (_pause_game >= 0) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1369 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1370 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1371 |
BuildFileList(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1372 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1373 |
ResetObjectToPlace(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1374 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1375 |
o_dir.type = FIOS_TYPE_DIRECT; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1376 |
switch (_saveload_mode) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1377 |
case SLD_SAVE_GAME: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1378 |
case SLD_LOAD_GAME: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1379 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1380 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1381 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1382 |
case SLD_SAVE_SCENARIO: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1383 |
case SLD_LOAD_SCENARIO: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1384 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1385 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1386 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1387 |
case SLD_LOAD_HEIGHTMAP: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1388 |
FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1389 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1390 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1391 |
default: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1392 |
ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1393 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1394 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1395 |
this->vscroll.cap = 10; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1396 |
this->resize.step_width = 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1397 |
this->resize.step_height = 10; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1398 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1399 |
this->FindWindowPlacementAndResize(desc); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1400 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1401 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1402 |
virtual ~SaveLoadWindow() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1403 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1404 |
/* pause is only used in single-player, non-editor mode, non menu mode */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1405 |
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1406 |
if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1407 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1408 |
FiosFreeSavegameList(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1409 |
ClrBit(_no_scroll, SCROLL_SAVE); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1410 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1411 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1412 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1413 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1414 |
int pos; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1415 |
int y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1416 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1417 |
SetVScrollCount(this, _fios_num); |
10645 | 1418 |
this->DrawWidgets(); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1419 |
DrawFiosTexts(this->width); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1420 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1421 |
if (_savegame_sort_dirty) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1422 |
_savegame_sort_dirty = false; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1423 |
MakeSortedSaveGameList(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1424 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1425 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1426 |
GfxFillRect(this->widget[7].left + 1, this->widget[7].top + 1, this->widget[7].right, this->widget[7].bottom, 0xD7); |
10645 | 1427 |
this->DrawSortButtonState(_savegame_sort_order & SORT_BY_NAME ? 2 : 3, _savegame_sort_order & SORT_DESCENDING ? SBS_DOWN : SBS_UP); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1428 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1429 |
y = this->widget[7].top + 1; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1430 |
for (pos = this->vscroll.pos; pos < _fios_num; pos++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1431 |
const FiosItem *item = _fios_list + pos; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1432 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1433 |
DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], this->width - 18); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1434 |
y += 10; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1435 |
if (y >= this->vscroll.cap * 10 + this->widget[7].top + 1) break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1436 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1437 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1438 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1439 |
this->DrawEditBox(10); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1440 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1441 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1442 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1443 |
virtual void OnClick(Point pt, int widget) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1444 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1445 |
switch (widget) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1446 |
case 2: // Sort save names by name |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1447 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ? |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1448 |
SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1449 |
_savegame_sort_dirty = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1450 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1451 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1452 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1453 |
case 3: // Sort save names by date |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1454 |
_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ? |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1455 |
SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1456 |
_savegame_sort_dirty = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1457 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1458 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1459 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1460 |
case 6: // OpenTTD 'button', jumps to OpenTTD directory |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1461 |
FiosBrowseTo(&o_dir); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1462 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1463 |
BuildFileList(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1464 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1465 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1466 |
case 7: { // Click the listbox |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1467 |
int y = (pt.y - this->widget[widget].top - 1) / 10; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1468 |
char *name; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1469 |
const FiosItem *file; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1470 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1471 |
if (y < 0 || (y += this->vscroll.pos) >= this->vscroll.count) return; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1472 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1473 |
file = _fios_list + y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1474 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1475 |
name = FiosBrowseTo(file); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1476 |
if (name != NULL) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1477 |
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1478 |
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1479 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1480 |
SetFiosType(file->type); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1481 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1482 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1483 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1484 |
delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1485 |
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1486 |
SetFiosType(file->type); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1487 |
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1488 |
ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1489 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1490 |
delete this; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1491 |
ShowHeightmapLoad(); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1492 |
} else { |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1493 |
/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1494 |
ttd_strlcpy(this->text.buf, file->title, this->text.maxlength); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1495 |
UpdateTextBufferSize(&this->text); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1496 |
this->InvalidateWidget(10); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1497 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1498 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1499 |
/* Changed directory, need repaint. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1500 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1501 |
BuildFileList(); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1502 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1503 |
break; |
2255
ddcaf9e333ff
(svn r2775) Deleting a file can fail, display an error message when it happens
tron
parents:
2201
diff
changeset
|
1504 |
} |
3288
91b3ed6a0885
(svn r4002) - Fix: Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
Darkvater
parents:
3287
diff
changeset
|
1505 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1506 |
case 10: // edit box |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1507 |
ShowOnScreenKeyboard(this, widget, 0, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1508 |
break; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1509 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1510 |
case 11: case 12: // Delete, Save game |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1511 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1512 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1513 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1514 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1515 |
virtual void OnMouseLoop() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1516 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1517 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1518 |
this->HandleEditBox(10); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1519 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1520 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1521 |
|
10645 | 1522 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1523 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1524 |
if (keycode == WKC_ESC) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1525 |
delete this; |
10645 | 1526 |
return ES_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1527 |
} |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1528 |
|
10645 | 1529 |
EventState state = ES_NOT_HANDLED; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1530 |
if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) && |
10645 | 1531 |
this->HandleEditBoxKey(10, key, keycode, state) == 1) { // Press Enter |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1532 |
this->HandleButtonClick(12); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1533 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1534 |
|
10645 | 1535 |
return state; |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1536 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1537 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1538 |
virtual void OnTimeout() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1539 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1540 |
/* This test protects against using widgets 11 and 12 which are only available |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1541 |
* in those two saveload mode */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1542 |
if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO)) return; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1543 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1544 |
if (this->IsWidgetLowered(11)) { // Delete button clicked |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1545 |
if (!FiosDelete(this->text.buf)) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1546 |
ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1547 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1548 |
BuildFileList(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1549 |
/* Reset file name to current date on successful delete */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1550 |
if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName(); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1551 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1552 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1553 |
UpdateTextBufferSize(&this->text); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1554 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1555 |
} else if (this->IsWidgetLowered(12)) { // Save button clicked |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1556 |
_switch_mode = SM_SAVE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1557 |
FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1558 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1559 |
/* In the editor set up the vehicle engines correctly (date might have changed) */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1560 |
if (_game_mode == GM_EDITOR) StartupEngines(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1561 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
1562 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1563 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1564 |
virtual void OnResize(Point new_size, Point delta) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1565 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1566 |
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1567 |
uint diff = delta.x / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1568 |
this->widget[2].right += diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1569 |
this->widget[3].left += diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1570 |
this->widget[3].right += delta.x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1571 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1572 |
/* Same for widget 11 and 12 in save-dialog */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1573 |
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1574 |
this->widget[11].right += diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1575 |
this->widget[12].left += diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1576 |
this->widget[12].right += delta.x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1577 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1578 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1579 |
this->vscroll.cap += delta.y / 10; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1580 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1581 |
}; |
0 | 1582 |
|
1583 |
static const WindowDesc _load_dialog_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1584 |
WDP_CENTER, WDP_CENTER, 257, 154, 257, 294, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1585 |
WC_SAVELOAD, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1586 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
5079
173056d957f5
(svn r7143) -CodeChange: remove redondancy in saveload dialogs
glx
parents:
5070
diff
changeset
|
1587 |
_load_dialog_widgets, |
0 | 1588 |
}; |
1589 |
||
1590 |
static const WindowDesc _save_dialog_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1591 |
WDP_CENTER, WDP_CENTER, 257, 180, 257, 320, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
1592 |
WC_SAVELOAD, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
1593 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 1594 |
_save_dialog_widgets, |
1595 |
}; |
|
1596 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1597 |
/** These values are used to convert the file/operations mode into a corresponding file type. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1598 |
* So each entry, as expressed by the related comment, is based on the enum */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1599 |
static const FileType _file_modetotype[] = { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1600 |
FT_SAVEGAME, ///< used for SLD_LOAD_GAME |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1601 |
FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1602 |
FT_SAVEGAME, ///< used for SLD_SAVE_GAME |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1603 |
FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1604 |
FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1605 |
FT_SAVEGAME, ///< SLD_NEW_GAME |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1606 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1607 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1608 |
void ShowSaveLoadDialog(SaveLoadDialogMode mode) |
0 | 1609 |
{ |
1610 |
DeleteWindowById(WC_QUERY_STRING, 0); |
|
1611 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
1612 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1613 |
const WindowDesc *sld; |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1392
diff
changeset
|
1614 |
switch (mode) { |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1615 |
case SLD_SAVE_GAME: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1616 |
case SLD_SAVE_SCENARIO: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1617 |
sld = &_save_dialog_desc; break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1618 |
default: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1619 |
sld = &_load_dialog_desc; break; |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1392
diff
changeset
|
1620 |
} |
0 | 1621 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1622 |
_saveload_mode = mode; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1623 |
_file_to_saveload.filetype = _file_modetotype[mode]; |
0 | 1624 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1625 |
new SaveLoadWindow(sld, mode); |
0 | 1626 |
} |
1627 |
||
6573 | 1628 |
void RedrawAutosave() |
0 | 1629 |
{ |
1630 |
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
|
1631 |
} |
|
1632 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1633 |
void SetFiosType(const byte fiostype) |
0 | 1634 |
{ |
1635 |
switch (fiostype) { |
|
2549 | 1636 |
case FIOS_TYPE_FILE: |
1637 |
case FIOS_TYPE_SCENARIO: |
|
1638 |
_file_to_saveload.mode = SL_LOAD; |
|
1639 |
break; |
|
1640 |
||
1641 |
case FIOS_TYPE_OLDFILE: |
|
1642 |
case FIOS_TYPE_OLD_SCENARIO: |
|
1643 |
_file_to_saveload.mode = SL_OLD_LOAD; |
|
1644 |
break; |
|
1645 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1646 |
#ifdef WITH_PNG |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1647 |
case FIOS_TYPE_PNG: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1648 |
_file_to_saveload.mode = SL_PNG; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1649 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1650 |
#endif /* WITH_PNG */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1651 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1652 |
case FIOS_TYPE_BMP: |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1653 |
_file_to_saveload.mode = SL_BMP; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1654 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1655 |
|
2549 | 1656 |
default: |
1657 |
_file_to_saveload.mode = SL_INVALID; |
|
1658 |
break; |
|
0 | 1659 |
} |
1660 |
} |