author | KUDr |
Sun, 14 Jan 2007 21:03:21 +0000 | |
changeset 5671 | c7b6e63f1996 |
parent 5668 | 36b39f4a9032 |
child 5672 | 86ab5e4289a5 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1885
diff
changeset
|
4 |
#include "openttd.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
5 |
#include "heightmap.h" |
2292 | 6 |
#include "currency.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
1349
15979a2e9001
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1336
diff
changeset
|
8 |
#include "spritecache.h" |
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
9 |
#include "station.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1230
diff
changeset
|
10 |
#include "strings.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1362
diff
changeset
|
11 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
12 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
670
diff
changeset
|
13 |
#include "map.h" |
1209
2e00193652b2
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1199
diff
changeset
|
14 |
#include "tile.h" |
0 | 15 |
#include "window.h" |
16 |
#include "gui.h" |
|
17 |
#include "viewport.h" |
|
18 |
#include "gfx.h" |
|
19 |
#include "player.h" |
|
20 |
#include "command.h" |
|
21 |
#include "news.h" |
|
22 |
#include "town.h" |
|
130
b593afdae262
(svn r131) Completely changed hotkey from tab to backquote (not working in Windows yet)
dominik
parents:
126
diff
changeset
|
23 |
#include "vehicle.h" |
126 | 24 |
#include "console.h" |
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
222
diff
changeset
|
25 |
#include "sound.h" |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5432
diff
changeset
|
26 |
#include "network/network.h" |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
27 |
#include "signs.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
28 |
#include "waypoint.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
29 |
#include "variables.h" |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2652
diff
changeset
|
30 |
#include "train.h" |
3310
a19f247b75b6
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3248
diff
changeset
|
31 |
#include "unmovable_map.h" |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
32 |
#include "string.h" |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
33 |
#include "screenshot.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
34 |
#include "genworld.h" |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
35 |
#include "settings.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4184
diff
changeset
|
36 |
#include "date.h" |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4634
diff
changeset
|
37 |
#include "vehicle_gui.h" |
5237
4fce3ea379c2
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
5235
diff
changeset
|
38 |
#include "newgrf_config.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
39 |
|
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5432
diff
changeset
|
40 |
#include "network/network_data.h" |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5432
diff
changeset
|
41 |
#include "network/network_client.h" |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5432
diff
changeset
|
42 |
#include "network/network_server.h" |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5432
diff
changeset
|
43 |
#include "network/network_gui.h" |
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4938
diff
changeset
|
44 |
#include "industry.h" |
0 | 45 |
|
5413 | 46 |
static int _rename_id = 1; |
47 |
static int _rename_what = -1; |
|
0 | 48 |
|
49 |
static byte _terraform_size = 1; |
|
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
50 |
RailType _last_built_railtype; |
5064
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
51 |
static int _scengen_town_size = 2; // depress medium-sized towns per default |
0 | 52 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
53 |
extern void GenerateIndustries(void); |
2430
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
54 |
extern bool GenerateTowns(void); |
0 | 55 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
56 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
57 |
void HandleOnEditText(const char *str) |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
58 |
{ |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
59 |
int id = _rename_id; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
60 |
_cmd_text = str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
61 |
|
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
62 |
switch (_rename_what) { |
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
63 |
case 0: /* Rename a s sign, if string is empty, delete sign */ |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1772
diff
changeset
|
64 |
DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)); |
0 | 65 |
break; |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
66 |
case 1: /* Rename a waypoint */ |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
67 |
if (*str == '\0') return; |
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
355
diff
changeset
|
68 |
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); |
0 | 69 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
70 |
#ifdef ENABLE_NETWORK |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
71 |
case 3: { /* Give money, you can only give money in excess of loan */ |
1962
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1932
diff
changeset
|
72 |
const Player *p = GetPlayer(_current_player); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
73 |
int32 money = min(p->money64 - p->current_loan, atoi(str) / _currency->rate); |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
74 |
char msg[20]; |
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
75 |
|
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
76 |
money = clamp(money, 0, 20000000); // Clamp between 20 million and 0 |
813
640a517dc129
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
793
diff
changeset
|
77 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
78 |
// Give 'id' the money, and substract it from ourself |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
79 |
if (!DoCommandP(0, money, id, NULL, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS))) break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
80 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
81 |
// Inform the player of this action |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
82 |
snprintf(msg, sizeof(msg), "%d", money); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
83 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
84 |
if (!_network_server) { |
5261
8e2633e0fbe7
(svn r7391) -Fix r6814: when sending money in multiplayer, the corresponding chat message was for the wrong player (off by one)
glx
parents:
5237
diff
changeset
|
85 |
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, id, msg); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
86 |
} else { |
5261
8e2633e0fbe7
(svn r7391) -Fix r6814: when sending money in multiplayer, the corresponding chat message was for the wrong player (off by one)
glx
parents:
5237
diff
changeset
|
87 |
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, id, msg, NETWORK_SERVER_INDEX); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
88 |
} |
5413 | 89 |
} break; |
90 |
#endif /* ENABLE_NETWORK */ |
|
91 |
default: NOT_REACHED(); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
92 |
} |
5413 | 93 |
|
94 |
_rename_id = _rename_what = -1; |
|
0 | 95 |
} |
96 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
97 |
/** |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
98 |
* This code is shared for the majority of the pushbuttons. |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
99 |
* Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
100 |
* |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
101 |
* @param w Window which called the function |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
102 |
* @param widget ID of the widget (=button) that called this function |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
103 |
* @param cursor How should the cursor image change? E.g. cursor with depot image in it |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
104 |
* @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
105 |
* @param placeproc Procedure which will be called when someone clicks on the map |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
106 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
107 |
* @return true if the button is clicked, false if it's unclicked |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
108 |
*/ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
109 |
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc) |
0 | 110 |
{ |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
111 |
if (IsWindowWidgetDisabled(w, widget)) return false; |
0 | 112 |
|
2621
2bacc2e9c68f
(svn r3159) Remove the read-only variable _no_button_sound
tron
parents:
2615
diff
changeset
|
113 |
SndPlayFx(SND_15_BEEP); |
0 | 114 |
SetWindowDirty(w); |
115 |
||
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
116 |
if (IsWindowWidgetLowered(w, widget)) { |
0 | 117 |
ResetObjectToPlace(); |
118 |
return false; |
|
119 |
} |
|
120 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
121 |
SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number); |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
122 |
LowerWindowWidget(w, widget); |
0 | 123 |
_place_proc = placeproc; |
124 |
return true; |
|
125 |
} |
|
126 |
||
127 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
128 |
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 129 |
{ |
541 | 130 |
if (success) SndPlayTileFx(SND_12_EXPLOSION, tile); |
0 | 131 |
} |
132 |
||
133 |
||
134 |
static void ToolbarPauseClick(Window *w) |
|
135 |
{ |
|
2549 | 136 |
if (_networking && !_network_server) return; // only server can pause the game |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
206
diff
changeset
|
137 |
|
2639 | 138 |
if (DoCommandP(0, _pause ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP); |
0 | 139 |
} |
140 |
||
141 |
static void ToolbarFastForwardClick(Window *w) |
|
142 |
{ |
|
143 |
_fast_forward ^= true; |
|
541 | 144 |
SndPlayFx(SND_15_BEEP); |
0 | 145 |
} |
146 |
||
147 |
||
410 | 148 |
static void MenuClickSettings(int index) |
0 | 149 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
150 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
151 |
case 0: ShowGameOptions(); return; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
152 |
case 1: ShowGameDifficulty(); return; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
153 |
case 2: ShowPatchesSelection(); return; |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5261
diff
changeset
|
154 |
case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return; |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
155 |
|
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
156 |
case 5: _display_opt ^= DO_SHOW_TOWN_NAMES; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
157 |
case 6: _display_opt ^= DO_SHOW_STATION_NAMES; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
158 |
case 7: _display_opt ^= DO_SHOW_SIGNS; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
159 |
case 8: _display_opt ^= DO_WAYPOINTS; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
160 |
case 9: _display_opt ^= DO_FULL_ANIMATION; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
161 |
case 10: _display_opt ^= DO_FULL_DETAIL; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
162 |
case 11: _display_opt ^= DO_TRANS_BUILDINGS; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
163 |
case 12: _display_opt ^= DO_TRANS_SIGNS; break; |
0 | 164 |
} |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
165 |
MarkWholeScreenDirty(); |
0 | 166 |
} |
167 |
||
410 | 168 |
static void MenuClickSaveLoad(int index) |
0 | 169 |
{ |
170 |
if (_game_mode == GM_EDITOR) { |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
171 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
172 |
case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
173 |
case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
174 |
case 2: AskExitToGameMenu(); break; |
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
175 |
case 4: HandleExitGameRequest(); break; |
0 | 176 |
} |
177 |
} else { |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
178 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
179 |
case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
180 |
case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
181 |
case 2: AskExitToGameMenu(); break; |
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
182 |
case 3: HandleExitGameRequest(); break; |
0 | 183 |
} |
184 |
} |
|
185 |
} |
|
186 |
||
410 | 187 |
static void MenuClickMap(int index) |
0 | 188 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
189 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
190 |
case 0: ShowSmallMap(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
191 |
case 1: ShowExtraViewPortWindow(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
192 |
case 2: ShowSignList(); break; |
0 | 193 |
} |
194 |
} |
|
195 |
||
410 | 196 |
static void MenuClickTown(int index) |
0 | 197 |
{ |
198 |
ShowTownDirectory(); |
|
199 |
} |
|
200 |
||
410 | 201 |
static void MenuClickScenMap(int index) |
0 | 202 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
203 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
204 |
case 0: ShowSmallMap(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
205 |
case 1: ShowExtraViewPortWindow(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
206 |
case 2: ShowSignList(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
207 |
case 3: ShowTownDirectory(); break; |
0 | 208 |
} |
209 |
} |
|
210 |
||
410 | 211 |
static void MenuClickSubsidies(int index) |
0 | 212 |
{ |
213 |
ShowSubsidiesList(); |
|
214 |
} |
|
215 |
||
410 | 216 |
static void MenuClickStations(int index) |
0 | 217 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
218 |
ShowPlayerStations((PlayerID)index); |
0 | 219 |
} |
220 |
||
410 | 221 |
static void MenuClickFinances(int index) |
0 | 222 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
223 |
ShowPlayerFinances((PlayerID)index); |
0 | 224 |
} |
225 |
||
410 | 226 |
static void MenuClickCompany(int index) |
0 | 227 |
{ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
228 |
if (_networking && index == 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
229 |
ShowClientList(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
230 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
231 |
if (_networking) index--; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
232 |
ShowPlayerCompany((PlayerID)index); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
233 |
} |
0 | 234 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
235 |
|
410 | 236 |
static void MenuClickGraphs(int index) |
0 | 237 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
238 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
239 |
case 0: ShowOperatingProfitGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
240 |
case 1: ShowIncomeGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
241 |
case 2: ShowDeliveredCargoGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
242 |
case 3: ShowPerformanceHistoryGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
243 |
case 4: ShowCompanyValueGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
244 |
case 5: ShowCargoPaymentRates(); break; |
0 | 245 |
} |
246 |
} |
|
247 |
||
410 | 248 |
static void MenuClickLeague(int index) |
0 | 249 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
250 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
251 |
case 0: ShowCompanyLeagueTable(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
252 |
case 1: ShowPerformanceRatingDetail(); break; |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
253 |
} |
0 | 254 |
} |
255 |
||
410 | 256 |
static void MenuClickIndustry(int index) |
0 | 257 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
258 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
259 |
case 0: ShowIndustryDirectory(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
260 |
case 1: ShowBuildIndustryWindow(); break; |
0 | 261 |
} |
262 |
} |
|
263 |
||
410 | 264 |
static void MenuClickShowTrains(int index) |
0 | 265 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
266 |
ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Train); |
0 | 267 |
} |
268 |
||
410 | 269 |
static void MenuClickShowRoad(int index) |
0 | 270 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
271 |
ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Road); |
0 | 272 |
} |
273 |
||
410 | 274 |
static void MenuClickShowShips(int index) |
0 | 275 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
276 |
ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Ship); |
0 | 277 |
} |
278 |
||
410 | 279 |
static void MenuClickShowAir(int index) |
0 | 280 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
281 |
ShowVehicleListWindow((PlayerID)index, INVALID_STATION, VEH_Aircraft); |
0 | 282 |
} |
283 |
||
410 | 284 |
static void MenuClickBuildRail(int index) |
0 | 285 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
286 |
_last_built_railtype = (RailType)index; |
0 | 287 |
ShowBuildRailToolbar(_last_built_railtype, -1); |
288 |
} |
|
289 |
||
410 | 290 |
static void MenuClickBuildRoad(int index) |
0 | 291 |
{ |
292 |
ShowBuildRoadToolbar(); |
|
293 |
} |
|
294 |
||
410 | 295 |
static void MenuClickBuildWater(int index) |
0 | 296 |
{ |
297 |
ShowBuildDocksToolbar(); |
|
298 |
} |
|
299 |
||
410 | 300 |
static void MenuClickBuildAir(int index) |
0 | 301 |
{ |
302 |
ShowBuildAirToolbar(); |
|
303 |
} |
|
304 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
305 |
#ifdef ENABLE_NETWORK |
4830
668bcb0a30b2
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4824
diff
changeset
|
306 |
void ShowNetworkGiveMoneyWindow(PlayerID player) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
307 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
308 |
_rename_id = player; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
309 |
_rename_what = 3; |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
310 |
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
311 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
312 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
313 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
314 |
void ShowRenameSignWindow(const Sign *si) |
0 | 315 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
316 |
_rename_id = si->index; |
0 | 317 |
_rename_what = 0; |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
318 |
ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, NULL, CS_ALPHANUMERAL); |
0 | 319 |
} |
320 |
||
2116 | 321 |
void ShowRenameWaypointWindow(const Waypoint *wp) |
0 | 322 |
{ |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
323 |
int id = wp->index; |
697
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
324 |
|
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
325 |
/* Are we allowed to change the name of the waypoint? */ |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
326 |
if (!CheckTileOwnership(wp->xy)) { |
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
872
diff
changeset
|
327 |
ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME, |
3422
a6eba3443452
(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
celestar
parents:
3326
diff
changeset
|
328 |
TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE); |
697
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
329 |
return; |
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
330 |
} |
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
331 |
|
0 | 332 |
_rename_id = id; |
333 |
_rename_what = 1; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
334 |
SetDParam(0, id); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
335 |
ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL); |
0 | 336 |
} |
337 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
338 |
static void SelectSignTool(void) |
0 | 339 |
{ |
2639 | 340 |
if (_cursor.sprite == SPR_CURSOR_SIGN) { |
0 | 341 |
ResetObjectToPlace(); |
2639 | 342 |
} else { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
343 |
SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, 1, 1, 0); |
0 | 344 |
_place_proc = PlaceProc_Sign; |
345 |
} |
|
346 |
} |
|
347 |
||
410 | 348 |
static void MenuClickForest(int index) |
0 | 349 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
350 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
351 |
case 0: ShowTerraformToolbar(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
352 |
case 1: ShowBuildTreesToolbar(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
353 |
case 2: SelectSignTool(); break; |
0 | 354 |
} |
355 |
} |
|
356 |
||
410 | 357 |
static void MenuClickMusicWindow(int index) |
0 | 358 |
{ |
359 |
ShowMusicWindow(); |
|
360 |
} |
|
361 |
||
410 | 362 |
static void MenuClickNewspaper(int index) |
0 | 363 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
364 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
365 |
case 0: ShowLastNewsMessage(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
366 |
case 1: ShowMessageOptions(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
367 |
case 2: ShowMessageHistory(); break; |
0 | 368 |
} |
369 |
} |
|
370 |
||
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
371 |
static void MenuClickSmallScreenshot(void) |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
372 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
373 |
SetScreenshotType(SC_VIEWPORT); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
374 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
375 |
|
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
376 |
static void MenuClickWorldScreenshot(void) |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
377 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
378 |
SetScreenshotType(SC_WORLD); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
379 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
380 |
|
410 | 381 |
static void MenuClickHelp(int index) |
0 | 382 |
{ |
2432
c48585a8b05f
(svn r2958) - Feature: [ 1258971 ] Menu option to toggle console. Mainly for MacOS's or PDA's. (toholio)
Darkvater
parents:
2430
diff
changeset
|
383 |
switch (index) { |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
384 |
case 0: PlaceLandBlockInfo(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
385 |
case 2: IConsoleSwitch(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
386 |
case 3: MenuClickSmallScreenshot(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
387 |
case 4: MenuClickWorldScreenshot(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
388 |
case 5: ShowAboutWindow(); break; |
0 | 389 |
} |
390 |
} |
|
391 |
||
2639 | 392 |
|
393 |
typedef void MenuClickedProc(int index); |
|
394 |
||
0 | 395 |
static MenuClickedProc * const _menu_clicked_procs[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
396 |
NULL, /* 0 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
397 |
NULL, /* 1 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
398 |
MenuClickSettings, /* 2 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
399 |
MenuClickSaveLoad, /* 3 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
400 |
MenuClickMap, /* 4 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
401 |
MenuClickTown, /* 5 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
402 |
MenuClickSubsidies, /* 6 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
403 |
MenuClickStations, /* 7 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
404 |
MenuClickFinances, /* 8 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
405 |
MenuClickCompany, /* 9 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
406 |
MenuClickGraphs, /* 10 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
407 |
MenuClickLeague, /* 11 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
408 |
MenuClickIndustry, /* 12 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
409 |
MenuClickShowTrains, /* 13 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
410 |
MenuClickShowRoad, /* 14 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
411 |
MenuClickShowShips, /* 15 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
412 |
MenuClickShowAir, /* 16 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
413 |
MenuClickScenMap, /* 17 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
414 |
NULL, /* 18 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
415 |
MenuClickBuildRail, /* 19 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
416 |
MenuClickBuildRoad, /* 20 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
417 |
MenuClickBuildWater, /* 21 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
418 |
MenuClickBuildAir, /* 22 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
419 |
MenuClickForest, /* 23 */ |
0 | 420 |
MenuClickMusicWindow, /* 24 */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
421 |
MenuClickNewspaper, /* 25 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
422 |
MenuClickHelp, /* 26 */ |
0 | 423 |
}; |
424 |
||
425 |
static void MenuWndProc(Window *w, WindowEvent *e) |
|
426 |
{ |
|
2639 | 427 |
switch (e->event) { |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
428 |
case WE_CREATE: w->widget[0].right = w->width - 1; break; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
429 |
|
0 | 430 |
case WE_PAINT: { |
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
431 |
int x, y; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
432 |
|
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
433 |
byte count = WP(w, menu_d).item_count; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
434 |
byte sel = WP(w, menu_d).sel_index; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
435 |
uint16 chk = WP(w, menu_d).checked_items; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
436 |
StringID string = WP(w, menu_d).string_id; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
437 |
byte dis = WP(w, menu_d).disabled_items; |
0 | 438 |
|
439 |
DrawWindowWidgets(w); |
|
440 |
||
441 |
x = 1; |
|
442 |
y = 1; |
|
443 |
||
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
444 |
for (; count != 0; count--, string++, sel--) { |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
445 |
byte color = HASBIT(dis, 0) ? 14 : (sel == 0) ? 12 : 16; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
446 |
if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
447 |
|
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
448 |
if (HASBIT(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
449 |
DrawString(x + 2, y, string, color); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
450 |
|
0 | 451 |
y += 10; |
452 |
chk >>= 1; |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
453 |
dis >>= 1; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
454 |
} |
0 | 455 |
} break; |
456 |
||
457 |
case WE_DESTROY: { |
|
458 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
459 |
RaiseWindowWidget(v, WP(w,menu_d).main_button); |
0 | 460 |
SetWindowDirty(v); |
461 |
return; |
|
462 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
463 |
|
0 | 464 |
case WE_POPUPMENU_SELECT: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
465 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
0 | 466 |
int action_id; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
467 |
|
0 | 468 |
|
469 |
if (index < 0) { |
|
470 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
471 |
if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
0 | 472 |
index = WP(w,menu_d).sel_index; |
473 |
} |
|
474 |
||
475 |
action_id = WP(w,menu_d).action_id; |
|
476 |
DeleteWindow(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
477 |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
478 |
if (index >= 0) { |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
479 |
assert((uint)index <= lengthof(_menu_clicked_procs)); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
480 |
_menu_clicked_procs[action_id](index); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
481 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
482 |
|
0 | 483 |
break; |
484 |
} |
|
2639 | 485 |
|
0 | 486 |
case WE_POPUPMENU_OVER: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
487 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
0 | 488 |
|
2639 | 489 |
if (index == -1 || index == WP(w,menu_d).sel_index) return; |
0 | 490 |
|
491 |
WP(w,menu_d).sel_index = index; |
|
492 |
SetWindowDirty(w); |
|
493 |
return; |
|
494 |
} |
|
495 |
} |
|
496 |
} |
|
497 |
||
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
498 |
/* Dynamic widget length determined by toolbar-string length. |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
499 |
* See PopupMainToolbMenu en MenuWndProc */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
500 |
static const Widget _menu_widgets[] = { |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
501 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 0, 0, 0, 0x0, STR_NULL}, |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
502 |
{ WIDGETS_END}, |
0 | 503 |
}; |
504 |
||
505 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
506 |
static const Widget _player_menu_widgets[] = { |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
507 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
508 |
{ WIDGETS_END}, |
0 | 509 |
}; |
510 |
||
511 |
||
512 |
static int GetPlayerIndexFromMenu(int index) |
|
513 |
{ |
|
514 |
if (index >= 0) { |
|
4171 | 515 |
const Player *p; |
2630 | 516 |
|
0 | 517 |
FOR_ALL_PLAYERS(p) { |
2639 | 518 |
if (p->is_active && --index < 0) return p->index; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
519 |
} |
0 | 520 |
} |
521 |
return -1; |
|
522 |
} |
|
523 |
||
524 |
static void UpdatePlayerMenuHeight(Window *w) |
|
525 |
{ |
|
4824
c49e6ffcb89a
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4822
diff
changeset
|
526 |
byte num = ActivePlayerCount(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
527 |
|
2639 | 528 |
// Increase one to fit in PlayerList in the menu when in network |
529 |
if (_networking && WP(w,menu_d).main_button == 9) num++; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
530 |
|
0 | 531 |
if (WP(w,menu_d).item_count != num) { |
532 |
WP(w,menu_d).item_count = num; |
|
533 |
SetWindowDirty(w); |
|
534 |
num = num * 10 + 2; |
|
535 |
w->height = num; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
536 |
w->widget[0].bottom = w->widget[0].top + num - 1; |
0 | 537 |
SetWindowDirty(w); |
538 |
} |
|
539 |
} |
|
540 |
||
3692 | 541 |
extern void DrawPlayerIcon(PlayerID pid, int x, int y); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
542 |
|
0 | 543 |
static void PlayerMenuWndProc(Window *w, WindowEvent *e) |
544 |
{ |
|
2639 | 545 |
switch (e->event) { |
0 | 546 |
case WE_PAINT: { |
547 |
int x,y; |
|
548 |
byte sel, color; |
|
549 |
Player *p; |
|
550 |
uint16 chk; |
|
551 |
||
552 |
UpdatePlayerMenuHeight(w); |
|
553 |
DrawWindowWidgets(w); |
|
554 |
||
555 |
x = 1; |
|
556 |
y = 1; |
|
557 |
sel = WP(w,menu_d).sel_index; |
|
558 |
chk = WP(w,menu_d).checked_items; // let this mean gray items. |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
559 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
560 |
// 9 = playerlist |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
561 |
if (_networking && WP(w,menu_d).main_button == 9) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
562 |
if (sel == 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
563 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
564 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
565 |
DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, 0x0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
566 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
567 |
sel--; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
568 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
569 |
|
0 | 570 |
FOR_ALL_PLAYERS(p) { |
571 |
if (p->is_active) { |
|
572 |
if (p->index == sel) { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
573 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
0 | 574 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
575 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
576 |
DrawPlayerIcon(p->index, x + 2, y + 1); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
577 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
578 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
579 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
580 |
SetDParam(2, GetPlayerNameString(p->index, 3)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
581 |
|
2150
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2147
diff
changeset
|
582 |
color = (p->index == sel) ? 0xC : 0x10; |
0 | 583 |
if (chk&1) color = 14; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
584 |
DrawString(x + 19, y, STR_7021, color); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
585 |
|
0 | 586 |
y += 10; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
587 |
} |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
588 |
chk >>= 1; |
0 | 589 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
590 |
|
0 | 591 |
break; |
592 |
} |
|
593 |
||
594 |
case WE_DESTROY: { |
|
595 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
596 |
RaiseWindowWidget(v, WP(w,menu_d).main_button); |
0 | 597 |
SetWindowDirty(v); |
598 |
return; |
|
599 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
600 |
|
0 | 601 |
case WE_POPUPMENU_SELECT: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
602 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
0 | 603 |
int action_id = WP(w,menu_d).action_id; |
604 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
605 |
// We have a new entry at the top of the list of menu 9 when networking |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
606 |
// so keep that in count |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
607 |
if (_networking && WP(w,menu_d).main_button == 9) { |
2639 | 608 |
if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
609 |
} else { |
|
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
610 |
index = GetPlayerIndexFromMenu(index); |
2639 | 611 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
612 |
|
0 | 613 |
if (index < 0) { |
614 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
615 |
if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
0 | 616 |
index = WP(w,menu_d).sel_index; |
617 |
} |
|
618 |
||
619 |
DeleteWindow(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
620 |
|
0 | 621 |
if (index >= 0) { |
622 |
assert(index >= 0 && index < 30); |
|
623 |
_menu_clicked_procs[action_id](index); |
|
624 |
} |
|
625 |
break; |
|
626 |
} |
|
627 |
case WE_POPUPMENU_OVER: { |
|
628 |
int index; |
|
629 |
UpdatePlayerMenuHeight(w); |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
630 |
index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
631 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
632 |
// We have a new entry at the top of the list of menu 9 when networking |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
633 |
// so keep that in count |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
634 |
if (_networking && WP(w,menu_d).main_button == 9) { |
2639 | 635 |
if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
636 |
} else { |
|
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
637 |
index = GetPlayerIndexFromMenu(index); |
2639 | 638 |
} |
639 |
||
640 |
if (index == -1 || index == WP(w,menu_d).sel_index) return; |
|
0 | 641 |
|
642 |
WP(w,menu_d).sel_index = index; |
|
643 |
SetWindowDirty(w); |
|
644 |
return; |
|
645 |
} |
|
646 |
} |
|
647 |
} |
|
648 |
||
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
649 |
/** Get the maximum length of a given string in a string-list. This is an |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
650 |
* implicit string-list where the ID's are consecutive |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
651 |
* @param base_string StringID of the first string in the list |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
652 |
* @param count amount of StringID's in the list |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
653 |
* @return the length of the longest string */ |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
654 |
static int GetStringListMaxWidth(StringID base_string, byte count) |
0 | 655 |
{ |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
656 |
char buffer[512]; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
657 |
int width, max_width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
658 |
byte i; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
659 |
|
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
660 |
max_width = 0; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
661 |
for (i = 0; i != count; i++) { |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4907
diff
changeset
|
662 |
GetString(buffer, base_string + i, lastof(buffer)); |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
663 |
width = GetStringBoundingBox(buffer).width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
664 |
if (width > max_width) max_width = width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
665 |
} |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
666 |
|
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
667 |
return max_width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
668 |
} |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
669 |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
670 |
/** Show a general dropdown menu. The positioning of the dropdown menu |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
671 |
* defaults to the left side of the parent_button, eg the button that caused |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
672 |
* this window to appear. The only exceptions are when the right side of this |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
673 |
* dropdown would fall outside the main toolbar window, in that case it is |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
674 |
* aligned with the toolbar's right side. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
675 |
* Since the disable-mask is only 8 bits right now, these dropdowns are |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
676 |
* restricted to 8 items max if any bits of disabled_mask are active. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
677 |
* @param w Pointer to a window this dropdown menu belongs to. Has no effect |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
678 |
* whatsoever, only graphically for positioning. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
679 |
* @param parent_button The widget identifier of the button that was clicked for |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
680 |
* this dropdown. The created dropdown then knows what button to raise (button) on |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
681 |
* action and whose function to execute (action). |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
682 |
* It is possible to appoint another button for an action event by setting the |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
683 |
* upper 8 bits of this parameter. If non is set, action is presumed to be the same |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
684 |
* as button. So<br> |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
685 |
* button bits 0 - 7 - widget clicked to get dropdown |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
686 |
* action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7) |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
687 |
* @param base_string The first StringID shown in the dropdown list. All others are |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
688 |
* consecutive indeces from the language file. XXX - fix? Use ingame-string tables? |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
689 |
* @param item_count Number of strings in the list, see previous parameter |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
690 |
* @param disabled_mask Bitmask of disabled strings in the list |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
691 |
* @return Return a pointer to the newly created dropdown window */ |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
692 |
static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask) |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
693 |
{ |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
694 |
int width; |
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
695 |
int x = w->widget[GB(parent_button, 0, 8)].left; |
0 | 696 |
|
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
697 |
assert(disabled_mask == 0 || item_count <= 8); |
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
698 |
LowerWindowWidget(w, parent_button); |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
699 |
InvalidateWidget(w, parent_button); |
0 | 700 |
|
701 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
702 |
||
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
703 |
/* Extend the dropdown toolbar to the longest string in the list and |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
704 |
* also make sure the dropdown is fully visible within the window. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
705 |
* x + w->left because x is supposed to be the offset of the toolbar-button |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
706 |
* we clicked on and w->left the toolbar window itself. So meaning that |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
707 |
* the default position is aligned with the left side of the clicked button */ |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
708 |
width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140); |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
709 |
x = w->left + clamp(x, 0, w->width - width); // or alternatively '_screen.width - width' |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
710 |
|
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
711 |
w = AllocateWindow(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
712 |
w->widget[0].bottom = item_count * 10 + 1; |
0 | 713 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
714 |
|
0 | 715 |
WP(w,menu_d).item_count = item_count; |
716 |
WP(w,menu_d).sel_index = 0; |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
717 |
WP(w,menu_d).main_button = GB(parent_button, 0, 8); |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
718 |
WP(w,menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; |
0 | 719 |
WP(w,menu_d).string_id = base_string; |
720 |
WP(w,menu_d).checked_items = 0; |
|
2216
cdedee39cc2b
(svn r2734) -Feature: The Main Toolbar Dropdown Menu can now display disabled items
celestar
parents:
2204
diff
changeset
|
721 |
WP(w,menu_d).disabled_items = disabled_mask; |
0 | 722 |
|
723 |
_popup_menu_active = true; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
724 |
|
541 | 725 |
SndPlayFx(SND_15_BEEP); |
0 | 726 |
return w; |
727 |
} |
|
728 |
||
729 |
static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int gray) |
|
730 |
{ |
|
731 |
x += w->left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
732 |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
733 |
LowerWindowWidget(w, main_button); |
0 | 734 |
InvalidateWidget(w, main_button); |
735 |
||
736 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
737 |
w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
|
738 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
|
739 |
WP(w,menu_d).item_count = 0; |
|
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
740 |
WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
741 |
if (_networking && main_button == 9) { |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
742 |
if (_local_player != PLAYER_SPECTATOR) { |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
743 |
WP(w,menu_d).sel_index++; |
2639 | 744 |
} else { |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
745 |
/* Select client list by default for spectators */ |
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
746 |
WP(w,menu_d).sel_index = 0; |
2639 | 747 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
748 |
} |
0 | 749 |
WP(w,menu_d).action_id = main_button; |
750 |
WP(w,menu_d).main_button = main_button; |
|
751 |
WP(w,menu_d).checked_items = gray; |
|
2216
cdedee39cc2b
(svn r2734) -Feature: The Main Toolbar Dropdown Menu can now display disabled items
celestar
parents:
2204
diff
changeset
|
752 |
WP(w,menu_d).disabled_items = 0; |
0 | 753 |
_popup_menu_active = true; |
541 | 754 |
SndPlayFx(SND_15_BEEP); |
0 | 755 |
return w; |
756 |
} |
|
757 |
||
758 |
static void ToolbarSaveClick(Window *w) |
|
759 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
760 |
PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0); |
0 | 761 |
} |
762 |
||
763 |
static void ToolbarMapClick(Window *w) |
|
764 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
765 |
PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0); |
0 | 766 |
} |
767 |
||
768 |
static void ToolbarTownClick(Window *w) |
|
769 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
770 |
PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0); |
0 | 771 |
} |
772 |
||
773 |
static void ToolbarSubsidiesClick(Window *w) |
|
774 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
775 |
PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0); |
0 | 776 |
} |
777 |
||
778 |
static void ToolbarStationsClick(Window *w) |
|
779 |
{ |
|
780 |
PopupMainPlayerToolbMenu(w, 162, 7, 0); |
|
781 |
} |
|
782 |
||
783 |
static void ToolbarMoneyClick(Window *w) |
|
784 |
{ |
|
785 |
PopupMainPlayerToolbMenu(w, 191, 8, 0); |
|
786 |
} |
|
787 |
||
788 |
static void ToolbarPlayersClick(Window *w) |
|
789 |
{ |
|
790 |
PopupMainPlayerToolbMenu(w, 213, 9, 0); |
|
791 |
} |
|
792 |
||
793 |
static void ToolbarGraphsClick(Window *w) |
|
794 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
795 |
PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0); |
0 | 796 |
} |
797 |
||
798 |
static void ToolbarLeagueClick(Window *w) |
|
799 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
800 |
PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0); |
0 | 801 |
} |
802 |
||
803 |
static void ToolbarIndustryClick(Window *w) |
|
804 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
805 |
/* Disable build-industry menu if we are a spectator */ |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
806 |
PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0); |
0 | 807 |
} |
808 |
||
809 |
static void ToolbarTrainClick(Window *w) |
|
810 |
{ |
|
4171 | 811 |
const Vehicle *v; |
0 | 812 |
int dis = -1; |
2639 | 813 |
|
814 |
FOR_ALL_VEHICLES(v) { |
|
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2652
diff
changeset
|
815 |
if (v->type == VEH_Train && IsFrontEngine(v)) CLRBIT(dis, v->owner); |
2639 | 816 |
} |
0 | 817 |
PopupMainPlayerToolbMenu(w, 310, 13, dis); |
818 |
} |
|
819 |
||
820 |
static void ToolbarRoadClick(Window *w) |
|
821 |
{ |
|
4171 | 822 |
const Vehicle *v; |
0 | 823 |
int dis = -1; |
2639 | 824 |
|
825 |
FOR_ALL_VEHICLES(v) { |
|
0 | 826 |
if (v->type == VEH_Road) CLRBIT(dis, v->owner); |
2639 | 827 |
} |
0 | 828 |
PopupMainPlayerToolbMenu(w, 332, 14, dis); |
829 |
} |
|
830 |
||
831 |
static void ToolbarShipClick(Window *w) |
|
832 |
{ |
|
4171 | 833 |
const Vehicle *v; |
0 | 834 |
int dis = -1; |
2639 | 835 |
|
836 |
FOR_ALL_VEHICLES(v) { |
|
0 | 837 |
if (v->type == VEH_Ship) CLRBIT(dis, v->owner); |
2639 | 838 |
} |
0 | 839 |
PopupMainPlayerToolbMenu(w, 354, 15, dis); |
840 |
} |
|
841 |
||
842 |
static void ToolbarAirClick(Window *w) |
|
843 |
{ |
|
4171 | 844 |
const Vehicle *v; |
0 | 845 |
int dis = -1; |
2639 | 846 |
|
847 |
FOR_ALL_VEHICLES(v) { |
|
0 | 848 |
if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner); |
2639 | 849 |
} |
0 | 850 |
PopupMainPlayerToolbMenu(w, 376, 16, dis); |
851 |
} |
|
852 |
||
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
853 |
/* Zooms a viewport in a window in or out */ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
854 |
/* No button handling or what so ever */ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
855 |
bool DoZoomInOutWindow(int how, Window *w) |
0 | 856 |
{ |
857 |
ViewPort *vp; |
|
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
858 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
859 |
assert(w != NULL); |
0 | 860 |
vp = w->viewport; |
861 |
||
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
862 |
switch (how) { |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
863 |
case ZOOM_IN: |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
864 |
if (vp->zoom == 0) return false; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
865 |
vp->zoom--; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
866 |
vp->virtual_width >>= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
867 |
vp->virtual_height >>= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
868 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
869 |
WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
870 |
WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
871 |
break; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
872 |
case ZOOM_OUT: |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
873 |
if (vp->zoom == 2) return false; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
874 |
vp->zoom++; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
875 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
876 |
WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
877 |
WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
878 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
879 |
vp->virtual_width <<= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
880 |
vp->virtual_height <<= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
881 |
break; |
0 | 882 |
} |
5214
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
883 |
if (vp != NULL) { // the vp can be null when how == ZOOM_NONE |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
884 |
vp->virtual_left = WP(w, vp_d).scrollpos_x; |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
885 |
vp->virtual_top = WP(w, vp_d).scrollpos_y; |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
886 |
} |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
887 |
SetWindowDirty(w); |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
888 |
/* Update the windows that have zoom-buttons to perhaps disable their buttons */ |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
889 |
SendWindowMessageClass(w->window_class, how, w->window_number, 0); |
0 | 890 |
return true; |
891 |
} |
|
892 |
||
893 |
static void ToolbarZoomInClick(Window *w) |
|
894 |
{ |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
895 |
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 896 |
HandleButtonClick(w, 17); |
541 | 897 |
SndPlayFx(SND_15_BEEP); |
0 | 898 |
} |
899 |
} |
|
900 |
||
901 |
static void ToolbarZoomOutClick(Window *w) |
|
902 |
{ |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
903 |
if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 904 |
HandleButtonClick(w, 18); |
541 | 905 |
SndPlayFx(SND_15_BEEP); |
0 | 906 |
} |
907 |
} |
|
908 |
||
909 |
static void ToolbarBuildRailClick(Window *w) |
|
910 |
{ |
|
4171 | 911 |
const Player *p = GetPlayer(_local_player); |
0 | 912 |
Window *w2; |
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
913 |
w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes); |
0 | 914 |
WP(w2,menu_d).sel_index = _last_built_railtype; |
915 |
} |
|
916 |
||
917 |
static void ToolbarBuildRoadClick(Window *w) |
|
918 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
919 |
PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 1, 0); |
0 | 920 |
} |
921 |
||
922 |
static void ToolbarBuildWaterClick(Window *w) |
|
923 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
924 |
PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0); |
0 | 925 |
} |
926 |
||
927 |
static void ToolbarBuildAirClick(Window *w) |
|
928 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
929 |
PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0); |
0 | 930 |
} |
931 |
||
932 |
static void ToolbarForestClick(Window *w) |
|
933 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
934 |
PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0); |
0 | 935 |
} |
936 |
||
937 |
static void ToolbarMusicClick(Window *w) |
|
938 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
939 |
PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0); |
0 | 940 |
} |
941 |
||
942 |
static void ToolbarNewspaperClick(Window *w) |
|
943 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
944 |
PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0); |
0 | 945 |
} |
946 |
||
947 |
static void ToolbarHelpClick(Window *w) |
|
948 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
949 |
PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0); |
0 | 950 |
} |
951 |
||
952 |
static void ToolbarOptionsClick(Window *w) |
|
953 |
{ |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
954 |
uint16 x = 0; |
0 | 955 |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
956 |
w = PopupMainToolbMenu(w, 2, STR_02C3_GAME_OPTIONS, 13, 0); |
0 | 957 |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
958 |
if (_display_opt & DO_SHOW_TOWN_NAMES) SETBIT(x, 5); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
959 |
if (_display_opt & DO_SHOW_STATION_NAMES) SETBIT(x, 6); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
960 |
if (_display_opt & DO_SHOW_SIGNS) SETBIT(x, 7); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
961 |
if (_display_opt & DO_WAYPOINTS) SETBIT(x, 8); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
962 |
if (_display_opt & DO_FULL_ANIMATION) SETBIT(x, 9); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
963 |
if (_display_opt & DO_FULL_DETAIL) SETBIT(x, 10); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
964 |
if (_display_opt & DO_TRANS_BUILDINGS) SETBIT(x, 11); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
965 |
if (_display_opt & DO_TRANS_SIGNS) SETBIT(x, 12); |
0 | 966 |
WP(w,menu_d).checked_items = x; |
967 |
} |
|
968 |
||
969 |
||
970 |
static void ToolbarScenSaveOrLoad(Window *w) |
|
971 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
972 |
PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 5, 0); |
0 | 973 |
} |
974 |
||
975 |
static void ToolbarScenDateBackward(Window *w) |
|
976 |
{ |
|
977 |
// don't allow too fast scrolling |
|
978 |
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
979 |
HandleButtonClick(w, 6); |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
980 |
SetWindowDirty(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
981 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
982 |
_patches_newgame.starting_year = clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
983 |
SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
0 | 984 |
} |
985 |
_left_button_clicked = false; |
|
986 |
} |
|
987 |
||
988 |
static void ToolbarScenDateForward(Window *w) |
|
989 |
{ |
|
990 |
// don't allow too fast scrolling |
|
991 |
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
992 |
HandleButtonClick(w, 7); |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
993 |
SetWindowDirty(w); |
0 | 994 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
995 |
_patches_newgame.starting_year = clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
996 |
SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
0 | 997 |
} |
998 |
_left_button_clicked = false; |
|
999 |
} |
|
1000 |
||
1001 |
static void ToolbarScenMapTownDir(Window *w) |
|
1002 |
{ |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
1003 |
/* Scenario editor button, *hack*hack* use different button to activate */ |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
1004 |
PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4, 0); |
0 | 1005 |
} |
1006 |
||
1007 |
static void ToolbarScenZoomIn(Window *w) |
|
1008 |
{ |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
1009 |
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 1010 |
HandleButtonClick(w, 9); |
541 | 1011 |
SndPlayFx(SND_15_BEEP); |
0 | 1012 |
} |
1013 |
} |
|
1014 |
||
1015 |
static void ToolbarScenZoomOut(Window *w) |
|
1016 |
{ |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
1017 |
if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 1018 |
HandleButtonClick(w, 10); |
541 | 1019 |
SndPlayFx(SND_15_BEEP); |
0 | 1020 |
} |
1021 |
} |
|
1022 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1023 |
void ZoomInOrOutToCursorWindow(bool in, Window *w) |
0 | 1024 |
{ |
4171 | 1025 |
ViewPort *vp; |
0 | 1026 |
Point pt; |
1027 |
||
1028 |
assert(w != 0); |
|
1029 |
||
1030 |
vp = w->viewport; |
|
1031 |
||
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1032 |
if (_game_mode != GM_MENU) { |
0 | 1033 |
if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
1034 |
return; |
|
1035 |
||
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
1036 |
pt = GetTileZoomCenterWindow(in,w); |
0 | 1037 |
if (pt.x != -1) { |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
1038 |
ScrollWindowTo(pt.x, pt.y, w); |
0 | 1039 |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
1040 |
DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
0 | 1041 |
} |
1042 |
} |
|
1043 |
} |
|
1044 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1045 |
// TODO - Incorporate into game itself to allow for ingame raising/lowering of |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1046 |
// larger chunks at the same time OR remove altogether, as we have 'level land' ? |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1047 |
/** |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1048 |
* Raise/Lower a bigger chunk of land at the same time in the editor. When |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1049 |
* raising get the lowest point, when lowering the highest point, and set all |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1050 |
* tiles in the selection to that height. |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1051 |
* @param tile The top-left tile where the terraforming will start |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1052 |
* @param mode 1 for raising, 0 for lowering land |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1053 |
*/ |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1054 |
static void CommonRaiseLowerBigLand(TileIndex tile, int mode) |
0 | 1055 |
{ |
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1056 |
int sizex, sizey; |
5601
d58f82901b2f
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents:
5587
diff
changeset
|
1057 |
uint h; |
0 | 1058 |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1059 |
_generating_world = true; // used to create green terraformed land |
0 | 1060 |
|
1061 |
if (_terraform_size == 1) { |
|
3182
0cec126ca9a9
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
3134
diff
changeset
|
1062 |
StringID msg = |
0cec126ca9a9
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
3134
diff
changeset
|
1063 |
mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE; |
0cec126ca9a9
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
3134
diff
changeset
|
1064 |
|
0cec126ca9a9
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
3134
diff
changeset
|
1065 |
DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(msg)); |
0 | 1066 |
} else { |
541 | 1067 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1068 |
|
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1069 |
assert(_terraform_size != 0); |
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1070 |
// check out for map overflows |
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1071 |
sizex = min(MapSizeX() - TileX(tile) - 1, _terraform_size); |
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1072 |
sizey = min(MapSizeY() - TileY(tile) - 1, _terraform_size); |
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1073 |
|
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1074 |
if (sizex == 0 || sizey == 0) return; |
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1075 |
|
0 | 1076 |
if (mode != 0) { |
1077 |
/* Raise land */ |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1078 |
h = 15; // XXX - max height |
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1079 |
BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) { |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1080 |
h = min(h, TileHeight(tile2)); |
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1081 |
} END_TILE_LOOP(tile2, sizex, sizey, tile) |
0 | 1082 |
} else { |
1083 |
/* Lower land */ |
|
1084 |
h = 0; |
|
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1085 |
BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) { |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1086 |
h = max(h, TileHeight(tile2)); |
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1087 |
} END_TILE_LOOP(tile2, sizex, sizey, tile) |
0 | 1088 |
} |
1089 |
||
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1090 |
BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) { |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1091 |
if (TileHeight(tile2) == h) { |
0 | 1092 |
DoCommandP(tile2, 8, (uint32)mode, NULL, CMD_TERRAFORM_LAND | CMD_AUTO); |
1093 |
} |
|
1697
95e9612b851d
(svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents:
1688
diff
changeset
|
1094 |
} END_TILE_LOOP(tile2, sizex, sizey, tile) |
0 | 1095 |
} |
1096 |
||
1097 |
_generating_world = false; |
|
1098 |
} |
|
1099 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1100 |
static void PlaceProc_RaiseBigLand(TileIndex tile) |
0 | 1101 |
{ |
1102 |
CommonRaiseLowerBigLand(tile, 1); |
|
1103 |
} |
|
1104 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1105 |
static void PlaceProc_LowerBigLand(TileIndex tile) |
0 | 1106 |
{ |
1107 |
CommonRaiseLowerBigLand(tile, 0); |
|
1108 |
} |
|
1109 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1110 |
static void PlaceProc_RockyArea(TileIndex tile) |
0 | 1111 |
{ |
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2571
diff
changeset
|
1112 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_RockyArea); |
0 | 1113 |
} |
1114 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1115 |
static void PlaceProc_LightHouse(TileIndex tile) |
0 | 1116 |
{ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3622
diff
changeset
|
1117 |
if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL))) { |
0 | 1118 |
return; |
2652
733e6877ccb1
(svn r3194) Don't use FindLandscapeHeightByTile() when it's overkill
tron
parents:
2643
diff
changeset
|
1119 |
} |
0 | 1120 |
|
3310
a19f247b75b6
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3248
diff
changeset
|
1121 |
MakeLighthouse(tile); |
a19f247b75b6
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3248
diff
changeset
|
1122 |
MarkTileDirtyByTile(tile); |
541 | 1123 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1124 |
} |
1125 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1126 |
static void PlaceProc_Transmitter(TileIndex tile) |
0 | 1127 |
{ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3622
diff
changeset
|
1128 |
if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL))) { |
0 | 1129 |
return; |
2652
733e6877ccb1
(svn r3194) Don't use FindLandscapeHeightByTile() when it's overkill
tron
parents:
2643
diff
changeset
|
1130 |
} |
0 | 1131 |
|
3310
a19f247b75b6
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3248
diff
changeset
|
1132 |
MakeTransmitter(tile); |
a19f247b75b6
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3248
diff
changeset
|
1133 |
MarkTileDirtyByTile(tile); |
541 | 1134 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1135 |
} |
1136 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1137 |
static void PlaceProc_DesertArea(TileIndex tile) |
0 | 1138 |
{ |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1139 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DesertArea); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1140 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1141 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1142 |
static void PlaceProc_WaterArea(TileIndex tile) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1143 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1144 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_WaterArea); |
0 | 1145 |
} |
1146 |
||
1147 |
static const Widget _scen_edit_land_gen_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2676
diff
changeset
|
1148 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1149 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0223_LAND_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1150 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 170, 181, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1151 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 181, 14, 95, 0x0, STR_NULL}, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1152 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 23, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
3134
e4f6fc217a29
(svn r3749) -Fix: [FS#61] The tooltips for raising and lowering land buttons in the scenario editor are interchanged (Reported and fixed by lc)
tron
parents:
2952
diff
changeset
|
1153 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 24, 45, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, |
e4f6fc217a29
(svn r3749) -Fix: [FS#61] The tooltips for raising and lowering land buttons in the scenario editor are interchanged (Reported and fixed by lc)
tron
parents:
2952
diff
changeset
|
1154 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 46, 67, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1155 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 68, 89, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1156 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 90, 111, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1157 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 112, 134, 14, 35, SPR_IMG_ROCKS, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1158 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 135, 157, 14, 35, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1159 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 158, 179, 14, 35, SPR_IMG_TRANSMITTER, STR_028E_PLACE_TRANSMITTER}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1160 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 43, 54, STR_0224, STR_0228_INCREASE_SIZE_OF_LAND_AREA}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1161 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 56, 67, STR_0225, STR_0229_DECREASE_SIZE_OF_LAND_AREA}, |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1162 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 34, 149, 75, 86, STR_SE_NEW_WORLD, STR_022A_GENERATE_RANDOM_LAND}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1163 |
{ WIDGETS_END}, |
0 | 1164 |
}; |
1165 |
||
1166 |
static const int8 _multi_terraform_coords[][2] = { |
|
1167 |
{ 0, -2}, |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1168 |
{ 4, 0}, { -4, 0}, { 0, 2}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1169 |
{ -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1170 |
{-12, 0}, { -8, -2}, { -4, -4}, { 0, -6}, { 4, -4}, { 8, -2}, { 12, 0}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1171 |
{-16, 2}, {-12, 4}, { -8, 6}, { -4, 8}, { 0, 10}, { 4, 8}, { 8, 6}, { 12, 4}, { 16, 2}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1172 |
{-20, 0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, { 0,-10}, { 4, -8}, { 8, -6}, { 12, -4}, { 16, -2}, { 20, 0}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1173 |
{-24, 2}, {-20, 4}, {-16, 6}, {-12, 8}, { -8, 10}, { -4, 12}, { 0, 14}, { 4, 12}, { 8, 10}, { 12, 8}, { 16, 6}, { 20, 4}, { 24, 2}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1174 |
{-28, 0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, { 0,-14}, { 4,-12}, { 8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28, 0}, |
0 | 1175 |
}; |
1176 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1177 |
// TODO - Merge with terraform_gui.c (move there) after I have cooled down at its braindeadness |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1178 |
// and changed OnButtonClick to include the widget as well in the function decleration. Post 0.4.0 - Darkvater |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1179 |
static void EditorTerraformClick_Dynamite(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1180 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1181 |
HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1182 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1183 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1184 |
static void EditorTerraformClick_LowerBigLand(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1185 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1186 |
HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1187 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1188 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1189 |
static void EditorTerraformClick_RaiseBigLand(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1190 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1191 |
HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1192 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1193 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1194 |
static void EditorTerraformClick_LevelLand(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1195 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1196 |
HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1197 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1198 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1199 |
static void EditorTerraformClick_WaterArea(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1200 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1201 |
HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, 1, PlaceProc_WaterArea); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1202 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1203 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1204 |
static void EditorTerraformClick_RockyArea(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1205 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1206 |
HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, 1, PlaceProc_RockyArea); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1207 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1208 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1209 |
static void EditorTerraformClick_DesertLightHouse(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1210 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1211 |
HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, 1, (_opt.landscape == LT_DESERT) ? PlaceProc_DesertArea : PlaceProc_LightHouse); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1212 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1213 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1214 |
static void EditorTerraformClick_Transmitter(Window *w) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1215 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1216 |
HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, 1, PlaceProc_Transmitter); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1217 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1218 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1219 |
static const uint16 _editor_terraform_keycodes[] = { |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1220 |
'D', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1221 |
'Q', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1222 |
'W', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1223 |
'E', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1224 |
'R', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1225 |
'T', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1226 |
'Y', |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1227 |
'U' |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1228 |
}; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1229 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1230 |
typedef void OnButtonClick(Window *w); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1231 |
static OnButtonClick * const _editor_terraform_button_proc[] = { |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1232 |
EditorTerraformClick_Dynamite, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1233 |
EditorTerraformClick_LowerBigLand, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1234 |
EditorTerraformClick_RaiseBigLand, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1235 |
EditorTerraformClick_LevelLand, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1236 |
EditorTerraformClick_WaterArea, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1237 |
EditorTerraformClick_RockyArea, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1238 |
EditorTerraformClick_DesertLightHouse, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1239 |
EditorTerraformClick_Transmitter |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1240 |
}; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1241 |
|
0 | 1242 |
static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) |
1243 |
{ |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1244 |
switch (e->event) { |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1245 |
case WE_CREATE: |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1246 |
// XXX - lighthouse button is widget 10!! Don't forget when changing |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1247 |
w->widget[10].tooltips = (_opt.landscape == LT_DESERT) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1248 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1249 |
|
0 | 1250 |
case WE_PAINT: |
1251 |
DrawWindowWidgets(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1252 |
|
0 | 1253 |
{ |
1254 |
int n = _terraform_size * _terraform_size; |
|
1255 |
const int8 *coords = &_multi_terraform_coords[0][0]; |
|
1256 |
||
1257 |
assert(n != 0); |
|
1258 |
do { |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
1259 |
DrawSprite(SPR_WHITE_POINT, PAL_NONE, 77 + coords[0], 55 + coords[1]); |
0 | 1260 |
coords += 2; |
1261 |
} while (--n); |
|
1262 |
} |
|
1263 |
||
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1264 |
if (IsWindowWidgetLowered(w, 5) || IsWindowWidgetLowered(w, 6)) // change area-size if raise/lower corner is selected |
0 | 1265 |
SetTileSelectSize(_terraform_size, _terraform_size); |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1266 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1267 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1268 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1269 |
case WE_KEYPRESS: { |
2639 | 1270 |
uint i; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1271 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1272 |
for (i = 0; i != lengthof(_editor_terraform_keycodes); i++) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1273 |
if (e->we.keypress.keycode == _editor_terraform_keycodes[i]) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1274 |
e->we.keypress.cont = false; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1275 |
_editor_terraform_button_proc[i](w); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1276 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1277 |
} |
0 | 1278 |
} |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1279 |
} break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1280 |
|
0 | 1281 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1282 |
switch (e->we.click.widget) { |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1283 |
case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1284 |
_editor_terraform_button_proc[e->we.click.widget - 4](w); |
0 | 1285 |
break; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1286 |
case 12: case 13: { /* Increase/Decrease terraform size */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1287 |
int size = (e->we.click.widget == 12) ? 1 : -1; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1288 |
HandleButtonClick(w, e->we.click.widget); |
0 | 1289 |
size += _terraform_size; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1290 |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
1291 |
if (!IS_INT_INSIDE(size, 1, 8 + 1)) return; |
0 | 1292 |
_terraform_size = size; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1293 |
|
541 | 1294 |
SndPlayFx(SND_15_BEEP); |
0 | 1295 |
SetWindowDirty(w); |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1296 |
} break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1297 |
case 14: /* gen random land */ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1298 |
HandleButtonClick(w, 14); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1299 |
ShowCreateScenario(); |
0 | 1300 |
break; |
1301 |
} |
|
1302 |
break; |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1303 |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1304 |
case WE_TIMEOUT: { |
5235
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5214
diff
changeset
|
1305 |
uint i; |
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5214
diff
changeset
|
1306 |
for (i = 0; i < w->widget_count; i++) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1307 |
if (IsWindowWidgetLowered(w, i)) { |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1308 |
RaiseWindowWidget(w, i); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1309 |
InvalidateWidget(w, i); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1310 |
} |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1311 |
if (i == 3) i = 11; |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1312 |
} |
0 | 1313 |
break; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1314 |
} |
0 | 1315 |
case WE_PLACE_OBJ: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1316 |
_place_proc(e->we.place.tile); |
0 | 1317 |
break; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1318 |
case WE_PLACE_DRAG: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1319 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1320 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1321 |
|
0 | 1322 |
case WE_PLACE_MOUSEUP: |
4994
aec94128f5d5
(svn r7000) -Fix: Incorrect use of e->we.click when the event is a 'place'. This didn't cause any
Darkvater
parents:
4942
diff
changeset
|
1323 |
if (e->we.place.pt.x != -1) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1324 |
if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1325 |
GUIPlaceProcDragXY(e); |
0 | 1326 |
} |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1327 |
break; |
0 | 1328 |
|
1329 |
case WE_ABORT_PLACE_OBJ: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1330 |
RaiseWindowButtons(w); |
0 | 1331 |
SetWindowDirty(w); |
1332 |
break; |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
1336 |
static const WindowDesc _scen_edit_land_gen_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1337 |
WDP_AUTO, WDP_AUTO, 182, 96, |
0 | 1338 |
WC_SCEN_LAND_GEN,0, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1339 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 1340 |
_scen_edit_land_gen_widgets, |
1341 |
ScenEditLandGenWndProc, |
|
1342 |
}; |
|
1343 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1344 |
static inline void ShowEditorTerraformToolBar(void) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1345 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1346 |
AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1347 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1348 |
|
0 | 1349 |
static void ToolbarScenGenLand(Window *w) |
1350 |
{ |
|
1351 |
HandleButtonClick(w, 11); |
|
541 | 1352 |
SndPlayFx(SND_15_BEEP); |
0 | 1353 |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1354 |
ShowEditorTerraformToolBar(); |
0 | 1355 |
} |
1356 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1357 |
void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 1358 |
{ |
1359 |
if (success) { |
|
541 | 1360 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1361 |
ResetObjectToPlace(); |
1362 |
} |
|
1363 |
} |
|
1364 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1365 |
static void PlaceProc_Town(TileIndex tile) |
0 | 1366 |
{ |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1367 |
DoCommandP(tile, _scengen_town_size, 0, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); |
0 | 1368 |
} |
1369 |
||
1370 |
||
1371 |
static const Widget _scen_edit_town_gen_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2676
diff
changeset
|
1372 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1373 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1374 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1375 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 159, 14, 81, 0x0, STR_NULL}, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1376 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 16, 27, STR_0234_NEW_TOWN, STR_0235_CONSTRUCT_NEW_TOWN}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1377 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 29, 40, STR_023D_RANDOM_TOWN, STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1378 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 42, 53, STR_MANY_RANDOM_TOWNS, STR_RANDOM_TOWNS_TIP}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1379 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 53, 68, 79, STR_02A1_SMALL, STR_02A4_SELECT_TOWN_SIZE}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1380 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 54, 105, 68, 79, STR_02A2_MEDIUM, STR_02A4_SELECT_TOWN_SIZE}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1381 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 106, 157, 68, 79, STR_02A3_LARGE, STR_02A4_SELECT_TOWN_SIZE}, |
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
1382 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 54, 67, STR_02A5_TOWN_SIZE, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1383 |
{ WIDGETS_END}, |
0 | 1384 |
}; |
1385 |
||
1386 |
static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) |
|
1387 |
{ |
|
2639 | 1388 |
switch (e->event) { |
0 | 1389 |
case WE_PAINT: |
1390 |
DrawWindowWidgets(w); |
|
1391 |
break; |
|
1392 |
||
3674
d6c991bdcbe1
(svn r4591) -Fix (FS#122) Game no longer errors out when "Many random towns" is selected in the scenario editor.
celestar
parents:
3636
diff
changeset
|
1393 |
case WE_CREATE: |
5064
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
1394 |
LowerWindowWidget(w, (_scengen_town_size - 1)+ 7); |
3674
d6c991bdcbe1
(svn r4591) -Fix (FS#122) Game no longer errors out when "Many random towns" is selected in the scenario editor.
celestar
parents:
3636
diff
changeset
|
1395 |
break; |
d6c991bdcbe1
(svn r4591) -Fix (FS#122) Game no longer errors out when "Many random towns" is selected in the scenario editor.
celestar
parents:
3636
diff
changeset
|
1396 |
|
0 | 1397 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1398 |
switch (e->we.click.widget) { |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1399 |
case 4: /* new town */ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1400 |
HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, 1, PlaceProc_Town); |
0 | 1401 |
break; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1402 |
case 5: {/* random town */ |
0 | 1403 |
Town *t; |
1404 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1405 |
HandleButtonClick(w, 5); |
0 | 1406 |
_generating_world = true; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1407 |
t = CreateRandomTown(20, _scengen_town_size); |
0 | 1408 |
_generating_world = false; |
2430
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
1409 |
|
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
1410 |
if (t == NULL) { |
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
1411 |
ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0); |
2639 | 1412 |
} else { |
0 | 1413 |
ScrollMainWindowToTile(t->xy); |
2639 | 1414 |
} |
2430
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
1415 |
|
0 | 1416 |
break; |
1417 |
} |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1418 |
case 6: {/* many random towns */ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1419 |
HandleButtonClick(w, 6); |
2430
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2429
diff
changeset
|
1420 |
|
0 | 1421 |
_generating_world = true; |
3674
d6c991bdcbe1
(svn r4591) -Fix (FS#122) Game no longer errors out when "Many random towns" is selected in the scenario editor.
celestar
parents:
3636
diff
changeset
|
1422 |
if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0); |
0 | 1423 |
_generating_world = false; |
1424 |
break; |
|
1425 |
} |
|
1426 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1427 |
case 7: case 8: case 9: |
5064
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
1428 |
RaiseWindowWidget(w, (_scengen_town_size - 1) + 7); |
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
1429 |
_scengen_town_size = (e->we.click.widget - 7) + 1; |
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
1430 |
LowerWindowWidget(w, (_scengen_town_size - 1) + 7); |
0 | 1431 |
SetWindowDirty(w); |
1432 |
break; |
|
1433 |
} |
|
1434 |
break; |
|
1435 |
||
1436 |
case WE_TIMEOUT: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1437 |
RaiseWindowWidget(w, 5); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1438 |
RaiseWindowWidget(w, 6); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1439 |
SetWindowDirty(w); |
0 | 1440 |
break; |
1441 |
case WE_PLACE_OBJ: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1442 |
_place_proc(e->we.place.tile); |
0 | 1443 |
break; |
1444 |
case WE_ABORT_PLACE_OBJ: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1445 |
RaiseWindowButtons(w); |
5064
a01edf90cfd3
(svn r7120) -Fix (r6631): A town size of 0 in the scenario editor is a random size. So to get a size
Darkvater
parents:
5048
diff
changeset
|
1446 |
LowerWindowWidget(w, (_scengen_town_size - 1) + 7); |
0 | 1447 |
SetWindowDirty(w); |
1448 |
break; |
|
1449 |
} |
|
1450 |
} |
|
1451 |
||
1452 |
static const WindowDesc _scen_edit_town_gen_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1453 |
WDP_AUTO, WDP_AUTO, 160, 82, |
0 | 1454 |
WC_SCEN_TOWN_GEN,0, |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1610
diff
changeset
|
1455 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 1456 |
_scen_edit_town_gen_widgets, |
1457 |
ScenEditTownGenWndProc, |
|
1458 |
}; |
|
1459 |
||
1460 |
static void ToolbarScenGenTown(Window *w) |
|
1461 |
{ |
|
1462 |
HandleButtonClick(w, 12); |
|
541 | 1463 |
SndPlayFx(SND_15_BEEP); |
0 | 1464 |
|
1465 |
AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0); |
|
1466 |
} |
|
1467 |
||
1468 |
||
1469 |
static const Widget _scenedit_industry_normal_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1470 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1471 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1472 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1473 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1474 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1475 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1476 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0240_COAL_MINE, STR_0262_CONSTRUCT_COAL_MINE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1477 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1478 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1479 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0243_FOREST, STR_0265_PLANT_FOREST}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1480 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1481 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_0245_OIL_RIG, STR_0267_CONSTRUCT_OIL_RIG_CAN_ONLY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1482 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1483 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1484 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1485 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_0249_IRON_ORE_MINE, STR_026B_CONSTRUCT_IRON_ORE_MINE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1486 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1487 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 185, 196, STR_024B_BANK, STR_026D_CONSTRUCT_BANK_CAN_ONLY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1488 |
{ WIDGETS_END}, |
0 | 1489 |
}; |
1490 |
||
1491 |
||
1492 |
static const Widget _scenedit_industry_hilly_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1493 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1494 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1495 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1496 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1497 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1498 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1499 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0240_COAL_MINE, STR_0262_CONSTRUCT_COAL_MINE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1500 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1501 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1502 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0243_FOREST, STR_0265_PLANT_FOREST}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1503 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1504 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1505 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1506 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_024F_GOLD_MINE, STR_0271_CONSTRUCT_GOLD_MINE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1507 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1508 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_024B_BANK, STR_0272_CONSTRUCT_BANK_CAN_ONLY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1509 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1510 |
{ WIDGETS_END}, |
0 | 1511 |
}; |
1512 |
||
1513 |
static const Widget _scenedit_industry_desert_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1514 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1515 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1516 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1517 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1518 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1519 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1520 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1521 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0251_FRUIT_PLANTATION, STR_0274_PLANT_FRUIT_PLANTATION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1522 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0252_RUBBER_PLANTATION, STR_0275_PLANT_RUBBER_PLANTATION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1523 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1524 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1525 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1526 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_0253_WATER_SUPPLY, STR_0276_CONSTRUCT_WATER_SUPPLY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1527 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1528 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1529 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1530 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024B_BANK, STR_0272_CONSTRUCT_BANK_CAN_ONLY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1531 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 185, 196, STR_0255_DIAMOND_MINE, STR_0278_CONSTRUCT_DIAMOND_MINE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1532 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 198, 209, STR_0256_COPPER_ORE_MINE, STR_0279_CONSTRUCT_COPPER_ORE_MINE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1533 |
{ WIDGETS_END}, |
0 | 1534 |
}; |
1535 |
||
1536 |
static const Widget _scenedit_industry_candy_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1537 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1538 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1539 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1540 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1541 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1542 |
|
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1543 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0257_COTTON_CANDY_FOREST, STR_027A_PLANT_COTTON_CANDY_FOREST}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1544 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1545 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0259_BATTERY_FARM, STR_027C_CONSTRUCT_BATTERY_FARM}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1546 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_025A_COLA_WELLS, STR_027D_CONSTRUCT_COLA_WELLS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1547 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1548 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1549 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_025D_PLASTIC_FOUNTAINS, STR_0280_CONSTRUCT_PLASTIC_FOUNTAINS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1550 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_025E_FIZZY_DRINK_FACTORY, STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1551 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_025F_BUBBLE_GENERATOR, STR_0282_CONSTRUCT_BUBBLE_GENERATOR}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1552 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_0260_TOFFEE_QUARRY, STR_0283_CONSTRUCT_TOFFEE_QUARRY}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1553 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_0261_SUGAR_MINE, STR_0284_CONSTRUCT_SUGAR_MINE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1554 |
{ WIDGETS_END}, |
0 | 1555 |
}; |
1556 |
||
1557 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
1558 |
static bool AnyTownExists(void) |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
1559 |
{ |
4171 | 1560 |
const Town *t; |
2630 | 1561 |
|
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4345
diff
changeset
|
1562 |
FOR_ALL_TOWNS(t) return true; |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4345
diff
changeset
|
1563 |
|
0 | 1564 |
return false; |
1565 |
} |
|
1566 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1567 |
extern Industry *CreateNewIndustry(TileIndex tile, IndustryType type); |
0 | 1568 |
|
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1569 |
/** |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1570 |
* Search callback function for TryBuildIndustry |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1571 |
* @param tile to test |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1572 |
* @param data that is passed by the caller. In this case, the type of industry been tested |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1573 |
* @result of the operation |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1574 |
*/ |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1575 |
static bool SearchTileForIndustry(TileIndex tile, uint32 data) |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1576 |
{ |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1577 |
return CreateNewIndustry(tile, data) != NULL; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1578 |
} |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1579 |
|
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1580 |
/** |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1581 |
* Perform a 9*9 tiles circular search around a tile |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1582 |
* in order to find a suitable zone to create the desired industry |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1583 |
* @param tile to start search for |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1584 |
* @param type of the desired industry |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1585 |
*/ |
0 | 1586 |
static bool TryBuildIndustry(TileIndex tile, int type) |
1587 |
{ |
|
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5116
diff
changeset
|
1588 |
return CircularTileSearch(tile, 9, SearchTileForIndustry, type); |
0 | 1589 |
} |
1590 |
||
1591 |
||
1592 |
static const byte _industry_type_list[4][16] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1593 |
{ 0, 1, 2, 3, 4, 5, 6, 8, 9, 18, 11, 12}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1594 |
{ 0, 1, 14, 3, 4, 13, 7, 15, 9, 16, 11, 12}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
1595 |
{25, 19, 20, 4, 13, 23, 21, 24, 22, 11, 16, 17, 10}, |
0 | 1596 |
{26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}, |
1597 |
}; |
|
1598 |
||
2630 | 1599 |
static int _industry_type_to_place; |
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1600 |
bool _ignore_restrictions; |
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1601 |
|
0 | 1602 |
static void ScenEditIndustryWndProc(Window *w, WindowEvent *e) |
1603 |
{ |
|
1604 |
int button; |
|
1605 |
||
2952 | 1606 |
switch (e->event) { |
0 | 1607 |
case WE_PAINT: |
1608 |
DrawWindowWidgets(w); |
|
1609 |
break; |
|
1610 |
||
1611 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1612 |
if (e->we.click.widget == 3) { |
0 | 1613 |
HandleButtonClick(w, 3); |
1614 |
||
2639 | 1615 |
if (!AnyTownExists()) { |
1616 |
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_CAN_T_GENERATE_INDUSTRIES, 0, 0); |
|
1617 |
return; |
|
1618 |
} |
|
0 | 1619 |
|
1620 |
_generating_world = true; |
|
1621 |
GenerateIndustries(); |
|
1622 |
_generating_world = false; |
|
1623 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1624 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1625 |
if ((button=e->we.click.widget) >= 4) { |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
1626 |
if (HandlePlacePushButton(w, button, SPR_CURSOR_INDUSTRY, 1, NULL)) |
0 | 1627 |
_industry_type_to_place = _industry_type_list[_opt.landscape][button - 4]; |
1628 |
} |
|
1629 |
break; |
|
1630 |
case WE_PLACE_OBJ: { |
|
1631 |
int type; |
|
1632 |
||
1633 |
// Show error if no town exists at all |
|
1634 |
type = _industry_type_to_place; |
|
1635 |
if (!AnyTownExists()) { |
|
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4938
diff
changeset
|
1636 |
SetDParam(0, GetIndustrySpec(type)->name); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1637 |
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y); |
0 | 1638 |
return; |
1639 |
} |
|
1640 |
||
1641 |
_current_player = OWNER_NONE; |
|
1642 |
_generating_world = true; |
|
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1643 |
_ignore_restrictions = true; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1644 |
if (!TryBuildIndustry(e->we.place.tile,type)) { |
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4938
diff
changeset
|
1645 |
SetDParam(0, GetIndustrySpec(type)->name); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1646 |
ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y); |
0 | 1647 |
} |
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1648 |
_ignore_restrictions = false; |
0 | 1649 |
_generating_world = false; |
1650 |
break; |
|
1651 |
} |
|
1652 |
case WE_ABORT_PLACE_OBJ: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1653 |
RaiseWindowButtons(w); |
0 | 1654 |
SetWindowDirty(w); |
1655 |
break; |
|
1656 |
case WE_TIMEOUT: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1657 |
RaiseWindowWidget(w, 3); |
5354
a48fc9a710f5
(svn r7525) -Fix (r6631): Invalidate the widget of 'many random industries' when it is raised (Maedhros)
Darkvater
parents:
5352
diff
changeset
|
1658 |
InvalidateWidget(w, 3); |
0 | 1659 |
break; |
1660 |
} |
|
1661 |
} |
|
1662 |
||
1663 |
static const WindowDesc _scenedit_industry_normal_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1664 |
WDP_AUTO, WDP_AUTO, 170, 225, |
0 | 1665 |
WC_SCEN_INDUSTRY,0, |
1666 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1667 |
_scenedit_industry_normal_widgets, |
|
1668 |
ScenEditIndustryWndProc, |
|
1669 |
}; |
|
1670 |
||
1671 |
static const WindowDesc _scenedit_industry_hilly_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1672 |
WDP_AUTO, WDP_AUTO, 170, 225, |
0 | 1673 |
WC_SCEN_INDUSTRY,0, |
1674 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1675 |
_scenedit_industry_hilly_widgets, |
|
1676 |
ScenEditIndustryWndProc, |
|
1677 |
}; |
|
1678 |
||
1679 |
static const WindowDesc _scenedit_industry_desert_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1680 |
WDP_AUTO, WDP_AUTO, 170, 225, |
0 | 1681 |
WC_SCEN_INDUSTRY,0, |
1682 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1683 |
_scenedit_industry_desert_widgets, |
|
1684 |
ScenEditIndustryWndProc, |
|
1685 |
}; |
|
1686 |
||
1687 |
static const WindowDesc _scenedit_industry_candy_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5064
diff
changeset
|
1688 |
WDP_AUTO, WDP_AUTO, 170, 225, |
0 | 1689 |
WC_SCEN_INDUSTRY,0, |
1690 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1691 |
_scenedit_industry_candy_widgets, |
|
1692 |
ScenEditIndustryWndProc, |
|
1693 |
}; |
|
1694 |
||
1695 |
static const WindowDesc * const _scenedit_industry_descs[] = { |
|
1696 |
&_scenedit_industry_normal_desc, |
|
1697 |
&_scenedit_industry_hilly_desc, |
|
1698 |
&_scenedit_industry_desert_desc, |
|
1699 |
&_scenedit_industry_candy_desc, |
|
1700 |
}; |
|
1701 |
||
1702 |
||
1703 |
static void ToolbarScenGenIndustry(Window *w) |
|
1704 |
{ |
|
1705 |
HandleButtonClick(w, 13); |
|
541 | 1706 |
SndPlayFx(SND_15_BEEP); |
0 | 1707 |
AllocateWindowDescFront(_scenedit_industry_descs[_opt.landscape],0); |
1708 |
} |
|
1709 |
||
1710 |
static void ToolbarScenBuildRoad(Window *w) |
|
1711 |
{ |
|
1712 |
HandleButtonClick(w, 14); |
|
541 | 1713 |
SndPlayFx(SND_15_BEEP); |
0 | 1714 |
ShowBuildRoadScenToolbar(); |
1715 |
} |
|
1716 |
||
1717 |
static void ToolbarScenPlantTrees(Window *w) |
|
1718 |
{ |
|
1719 |
HandleButtonClick(w, 15); |
|
541 | 1720 |
SndPlayFx(SND_15_BEEP); |
0 | 1721 |
ShowBuildTreesScenToolbar(); |
1722 |
} |
|
1723 |
||
1724 |
static void ToolbarScenPlaceSign(Window *w) |
|
1725 |
{ |
|
1726 |
HandleButtonClick(w, 16); |
|
541 | 1727 |
SndPlayFx(SND_15_BEEP); |
0 | 1728 |
SelectSignTool(); |
1729 |
} |
|
1730 |
||
1731 |
static void ToolbarBtn_NULL(Window *w) |
|
1732 |
{ |
|
1733 |
} |
|
1734 |
||
2639 | 1735 |
|
1736 |
typedef void ToolbarButtonProc(Window *w); |
|
1737 |
||
4171 | 1738 |
static ToolbarButtonProc * const _toolbar_button_procs[] = { |
0 | 1739 |
ToolbarPauseClick, |
1740 |
ToolbarFastForwardClick, |
|
1741 |
ToolbarOptionsClick, |
|
1742 |
ToolbarSaveClick, |
|
1743 |
ToolbarMapClick, |
|
1744 |
ToolbarTownClick, |
|
1745 |
ToolbarSubsidiesClick, |
|
1746 |
ToolbarStationsClick, |
|
1747 |
ToolbarMoneyClick, |
|
1748 |
ToolbarPlayersClick, |
|
1749 |
ToolbarGraphsClick, |
|
1750 |
ToolbarLeagueClick, |
|
1751 |
ToolbarIndustryClick, |
|
1752 |
ToolbarTrainClick, |
|
1753 |
ToolbarRoadClick, |
|
1754 |
ToolbarShipClick, |
|
1755 |
ToolbarAirClick, |
|
1756 |
ToolbarZoomInClick, |
|
1757 |
ToolbarZoomOutClick, |
|
1758 |
ToolbarBuildRailClick, |
|
1759 |
ToolbarBuildRoadClick, |
|
1760 |
ToolbarBuildWaterClick, |
|
1761 |
ToolbarBuildAirClick, |
|
1762 |
ToolbarForestClick, |
|
1763 |
ToolbarMusicClick, |
|
1764 |
ToolbarNewspaperClick, |
|
1765 |
ToolbarHelpClick, |
|
1766 |
}; |
|
1767 |
||
1768 |
static void MainToolbarWndProc(Window *w, WindowEvent *e) |
|
1769 |
{ |
|
2952 | 1770 |
switch (e->event) { |
4781
3e0c04509b05
(svn r6695) -Fix FS#356: disable main toolbar buttons showing company list drop downs when there are no companies
glx
parents:
4748
diff
changeset
|
1771 |
case WE_PAINT: |
0 | 1772 |
// Draw brown-red toolbar bg. |
1773 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
1774 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT)); |
0 | 1775 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1776 |
/* If spectator, disable all construction buttons |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1777 |
* ie : Build road, rail, ships, airports and landscaping |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1778 |
* Since enabled state is the default, just disable when needed */ |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
1779 |
SetWindowWidgetsDisabledState(w, _current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END); |
4781
3e0c04509b05
(svn r6695) -Fix FS#356: disable main toolbar buttons showing company list drop downs when there are no companies
glx
parents:
4748
diff
changeset
|
1780 |
/* disable company list drop downs, if there are no companies */ |
3e0c04509b05
(svn r6695) -Fix FS#356: disable main toolbar buttons showing company list drop downs when there are no companies
glx
parents:
4748
diff
changeset
|
1781 |
SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END); |
0 | 1782 |
|
1783 |
DrawWindowWidgets(w); |
|
1784 |
break; |
|
1785 |
||
1786 |
case WE_CLICK: { |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1787 |
if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget)) |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1788 |
_toolbar_button_procs[e->we.click.widget](w); |
0 | 1789 |
} break; |
1790 |
||
1791 |
case WE_KEYPRESS: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1792 |
switch (e->we.keypress.keycode) { |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1793 |
case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break; |
0 | 1794 |
case WKC_F2: ShowGameOptions(); break; |
1795 |
case WKC_F3: MenuClickSaveLoad(0); break; |
|
1796 |
case WKC_F4: ShowSmallMap(); break; |
|
1797 |
case WKC_F5: ShowTownDirectory(); break; |
|
1798 |
case WKC_F6: ShowSubsidiesList(); break; |
|
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1799 |
case WKC_F7: ShowPlayerStations(_local_player); break; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1800 |
case WKC_F8: ShowPlayerFinances(_local_player); break; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1801 |
case WKC_F9: ShowPlayerCompany(_local_player); break; |
0 | 1802 |
case WKC_F10:ShowOperatingProfitGraph(); break; |
1803 |
case WKC_F11: ShowCompanyLeagueTable(); break; |
|
1804 |
case WKC_F12: ShowBuildIndustryWindow(); break; |
|
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1805 |
case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Train); break; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1806 |
case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Road); break; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1807 |
case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Ship); break; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1808 |
case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Aircraft); break; |
0 | 1809 |
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break; |
1810 |
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break; |
|
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
1811 |
case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype, -1); break; |
0 | 1812 |
case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(); break; |
1813 |
case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break; |
|
1814 |
case WKC_SHIFT | WKC_F10:ShowBuildAirToolbar(); break; |
|
1815 |
case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break; |
|
1816 |
case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break; |
|
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
1817 |
case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
1818 |
case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1819 |
case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break; |
1636
060fc7b40cb8
(svn r2140) - Fix: [ 1175726 ] Allows rails in scenario editor. Moved both 'A' autorail and 'L' Terraform toolbar to their REAL places instead of the global window.
Darkvater
parents:
1633
diff
changeset
|
1820 |
case 'A': ShowBuildRailToolbar(_last_built_railtype, 4); break; /* Invoke Autorail */ |
060fc7b40cb8
(svn r2140) - Fix: [ 1175726 ] Allows rails in scenario editor. Moved both 'A' autorail and 'L' Terraform toolbar to their REAL places instead of the global window.
Darkvater
parents:
1633
diff
changeset
|
1821 |
case 'L': ShowTerraformToolbar(); break; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1822 |
default: return; |
1637
ee2049729147
(svn r2141) - Fix: Keys now hopefully only activate the right windows. If console/querybox/chatbox is open, all input goes there, if closed to game itself.
Darkvater
parents:
1636
diff
changeset
|
1823 |
} |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1824 |
e->we.keypress.cont = false; |
0 | 1825 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1826 |
|
0 | 1827 |
case WE_PLACE_OBJ: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1828 |
_place_proc(e->we.place.tile); |
0 | 1829 |
} break; |
1830 |
||
1831 |
case WE_ABORT_PLACE_OBJ: { |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1832 |
RaiseWindowWidget(w, 25); |
0 | 1833 |
SetWindowDirty(w); |
1834 |
} break; |
|
1835 |
||
1836 |
case WE_MOUSELOOP: |
|
4748
8a928d86a56c
(svn r6660) -Fix(r6631): Prevent the fast-foward button to toggle up and down when pressing shift.
belugas
parents:
4719
diff
changeset
|
1837 |
if (IsWindowWidgetLowered(w, 0) != !!_pause) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1838 |
ToggleWidgetLoweredState(w, 0); |
5413 | 1839 |
InvalidateWidget(w, 0); |
0 | 1840 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1841 |
|
4748
8a928d86a56c
(svn r6660) -Fix(r6631): Prevent the fast-foward button to toggle up and down when pressing shift.
belugas
parents:
4719
diff
changeset
|
1842 |
if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1843 |
ToggleWidgetLoweredState(w, 1); |
5413 | 1844 |
InvalidateWidget(w, 1); |
0 | 1845 |
} |
1846 |
break; |
|
1847 |
||
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1848 |
case WE_TIMEOUT: { |
5235
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5214
diff
changeset
|
1849 |
uint i; |
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5214
diff
changeset
|
1850 |
for (i = 2; i < w->widget_count; i++) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1851 |
if (IsWindowWidgetLowered(w, i)) { |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1852 |
RaiseWindowWidget(w, i); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1853 |
InvalidateWidget(w, i); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1854 |
} |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1855 |
} |
0 | 1856 |
break; |
1857 |
} |
|
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1858 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1859 |
case WE_MESSAGE: |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1860 |
HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18); |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1861 |
break; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1862 |
} |
0 | 1863 |
} |
1864 |
||
1865 |
static const Widget _toolb_normal_widgets[] = { |
|
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1866 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 0, 21, SPR_IMG_PAUSE, STR_0171_PAUSE_GAME}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1867 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1868 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 0, 21, SPR_IMG_SETTINGS, STR_0187_OPTIONS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1869 |
{ WWT_IMGBTN_2, RESIZE_NONE, 14, 66, 87, 0, 21, SPR_IMG_SAVE, STR_0172_SAVE_GAME_ABANDON_GAME}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1870 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1871 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 96, 117, 0, 21, SPR_IMG_SMALLMAP, STR_0174_DISPLAY_MAP}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1872 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 118, 139, 0, 21, SPR_IMG_TOWN, STR_0176_DISPLAY_TOWN_DIRECTORY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1873 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 140, 161, 0, 21, SPR_IMG_SUBSIDIES, STR_02DC_DISPLAY_SUBSIDIES}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1874 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 162, 183, 0, 21, SPR_IMG_COMPANY_LIST, STR_0173_DISPLAY_LIST_OF_COMPANY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1875 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1876 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 191, 212, 0, 21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1877 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 213, 235, 0, 21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1878 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 236, 257, 0, 21, SPR_IMG_GRAPHS, STR_0179_DISPLAY_GRAPHS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1879 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 258, 279, 0, 21, SPR_IMG_COMPANY_LEAGUE, STR_017A_DISPLAY_COMPANY_LEAGUE}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1880 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 280, 301, 0, 21, SPR_IMG_INDUSTRY, STR_0312_FUND_CONSTRUCTION_OF_NEW}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1881 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1882 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 310, 331, 0, 21, SPR_IMG_TRAINLIST, STR_017B_DISPLAY_LIST_OF_COMPANY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1883 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 332, 353, 0, 21, SPR_IMG_TRUCKLIST, STR_017C_DISPLAY_LIST_OF_COMPANY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1884 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 354, 375, 0, 21, SPR_IMG_SHIPLIST, STR_017D_DISPLAY_LIST_OF_COMPANY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1885 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 376, 397, 0, 21, SPR_IMG_AIRPLANESLIST, STR_017E_DISPLAY_LIST_OF_COMPANY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1886 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1887 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 406, 427, 0, 21, SPR_IMG_ZOOMIN, STR_017F_ZOOM_THE_VIEW_IN}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1888 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 428, 449, 0, 21, SPR_IMG_ZOOMOUT, STR_0180_ZOOM_THE_VIEW_OUT}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1889 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1890 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 457, 478, 0, 21, SPR_IMG_BUILDRAIL, STR_0181_BUILD_RAILROAD_TRACK}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1891 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 479, 500, 0, 21, SPR_IMG_BUILDROAD, STR_0182_BUILD_ROADS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1892 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 501, 522, 0, 21, SPR_IMG_BUILDWATER, STR_0183_BUILD_SHIP_DOCKS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1893 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 523, 544, 0, 21, SPR_IMG_BUILDAIR, STR_0184_BUILD_AIRPORTS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1894 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 545, 566, 0, 21, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6 |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1895 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1896 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 574, 595, 0, 21, SPR_IMG_MUSIC, STR_01D4_SHOW_SOUND_MUSIC_WINDOW}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1897 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 596, 617, 0, 21, SPR_IMG_MESSAGES, STR_0203_SHOW_LAST_MESSAGE_NEWS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1898 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 618, 639, 0, 21, SPR_IMG_QUERY, STR_0186_LAND_BLOCK_INFORMATION}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1899 |
{ WIDGETS_END}, |
0 | 1900 |
}; |
1901 |
||
1902 |
static const WindowDesc _toolb_normal_desc = { |
|
1903 |
0, 0, 640, 22, |
|
1904 |
WC_MAIN_TOOLBAR,0, |
|
1905 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
|
1906 |
_toolb_normal_widgets, |
|
1907 |
MainToolbarWndProc |
|
1908 |
}; |
|
1909 |
||
1910 |
||
1911 |
static const Widget _toolb_scen_widgets[] = { |
|
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1912 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 0, 21, SPR_IMG_PAUSE, STR_0171_PAUSE_GAME}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1913 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1914 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 0, 21, SPR_IMG_SETTINGS, STR_0187_OPTIONS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1915 |
{WWT_IMGBTN_2, RESIZE_NONE, 14, 66, 87, 0, 21, SPR_IMG_SAVE, STR_0297_SAVE_SCENARIO_LOAD_SCENARIO}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1916 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1917 |
{ WWT_PANEL, RESIZE_NONE, 14, 96, 225, 0, 21, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1918 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1919 |
{ WWT_PANEL, RESIZE_NONE, 14, 233, 362, 0, 21, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1920 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 236, 247, 5, 16, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1921 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 347, 358, 5, 16, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1922 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1923 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 371, 392, 0, 21, SPR_IMG_SMALLMAP, STR_0175_DISPLAY_MAP_TOWN_DIRECTORY}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1924 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1925 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 400, 421, 0, 21, SPR_IMG_ZOOMIN, STR_017F_ZOOM_THE_VIEW_IN}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1926 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 422, 443, 0, 21, SPR_IMG_ZOOMOUT, STR_0180_ZOOM_THE_VIEW_OUT}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1927 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1928 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 452, 473, 0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1929 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 474, 495, 0, 21, SPR_IMG_TOWN, STR_022F_TOWN_GENERATION}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1930 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 496, 517, 0, 21, SPR_IMG_INDUSTRY, STR_0230_INDUSTRY_GENERATION}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1931 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 518, 539, 0, 21, SPR_IMG_BUILDROAD, STR_0231_ROAD_CONSTRUCTION}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1932 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 540, 561, 0, 21, SPR_IMG_PLANTTREES, STR_0288_PLANT_TREES}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1933 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 562, 583, 0, 21, SPR_IMG_SIGN, STR_0289_PLACE_SIGN}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1934 |
|
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1935 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1936 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1937 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1938 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1939 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1940 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1941 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1942 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 596, 617, 0, 21, SPR_IMG_MUSIC, STR_01D4_SHOW_SOUND_MUSIC_WINDOW}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1943 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
1944 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 618, 639, 0, 21, SPR_IMG_QUERY, STR_0186_LAND_BLOCK_INFORMATION}, |
3248
adb982de0b02
(svn r3931) - [ 1451726 ] Use sprite names in main_gui.c instead of numbers (matthewwalton)
Darkvater
parents:
3182
diff
changeset
|
1945 |
{WIDGETS_END}, |
0 | 1946 |
}; |
1947 |
||
4171 | 1948 |
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = { |
0 | 1949 |
ToolbarPauseClick, |
1950 |
ToolbarFastForwardClick, |
|
1951 |
ToolbarOptionsClick, |
|
1952 |
ToolbarScenSaveOrLoad, |
|
1953 |
ToolbarBtn_NULL, |
|
1954 |
ToolbarBtn_NULL, |
|
1955 |
ToolbarScenDateBackward, |
|
1956 |
ToolbarScenDateForward, |
|
1957 |
ToolbarScenMapTownDir, |
|
1958 |
ToolbarScenZoomIn, |
|
1959 |
ToolbarScenZoomOut, |
|
1960 |
ToolbarScenGenLand, |
|
1961 |
ToolbarScenGenTown, |
|
1962 |
ToolbarScenGenIndustry, |
|
1963 |
ToolbarScenBuildRoad, |
|
1964 |
ToolbarScenPlantTrees, |
|
1965 |
ToolbarScenPlaceSign, |
|
1966 |
NULL, |
|
1967 |
NULL, |
|
1968 |
NULL, |
|
1969 |
NULL, |
|
1970 |
NULL, |
|
1971 |
NULL, |
|
1972 |
NULL, |
|
1973 |
ToolbarMusicClick, |
|
1974 |
NULL, |
|
1975 |
ToolbarHelpClick, |
|
1976 |
}; |
|
1977 |
||
1978 |
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) |
|
1979 |
{ |
|
2952 | 1980 |
switch (e->event) { |
0 | 1981 |
case WE_PAINT: |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1982 |
SetWindowWidgetDisabledState(w, 6, _patches_newgame.starting_year <= MIN_YEAR); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
1983 |
SetWindowWidgetDisabledState(w, 7, _patches_newgame.starting_year >= MAX_YEAR); |
349
518d84a83723
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
1984 |
|
0 | 1985 |
// Draw brown-red toolbar bg. |
1986 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
1987 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT)); |
0 | 1988 |
|
1989 |
DrawWindowWidgets(w); |
|
1990 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1991 |
SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
0 | 1992 |
DrawStringCentered(298, 6, STR_00AF, 0); |
1993 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1994 |
SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
74
d23a80ef6361
(svn r75) -Add proper crediting to graphics artists to about box.
darkvater
parents:
68
diff
changeset
|
1995 |
DrawStringCentered(161, 1, STR_0221_OPENTTD, 0); |
0 | 1996 |
DrawStringCentered(161, 11,STR_0222_SCENARIO_EDITOR, 0); |
1997 |
||
1998 |
break; |
|
1999 |
||
2000 |
case WE_CLICK: { |
|
2639 | 2001 |
if (_game_mode == GM_MENU) return; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2002 |
_scen_toolbar_button_procs[e->we.click.widget](w); |
0 | 2003 |
} break; |
2004 |
||
2755
ba133949851b
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2753
diff
changeset
|
2005 |
case WE_KEYPRESS: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2006 |
switch (e->we.keypress.keycode) { |
5006
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2007 |
case WKC_F1: ToolbarPauseClick(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2008 |
case WKC_F2: ShowGameOptions(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2009 |
case WKC_F3: MenuClickSaveLoad(0); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2010 |
case WKC_F4: ToolbarScenGenLand(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2011 |
case WKC_F5: ToolbarScenGenTown(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2012 |
case WKC_F6: ToolbarScenGenIndustry(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2013 |
case WKC_F7: ToolbarScenBuildRoad(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2014 |
case WKC_F8: ToolbarScenPlantTrees(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2015 |
case WKC_F9: ToolbarScenPlaceSign(w); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2016 |
case WKC_F10: ShowMusicWindow(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2017 |
case WKC_F11: PlaceLandBlockInfo(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2018 |
case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2019 |
case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2020 |
case 'L': ShowEditorTerraformToolBar(); break; |
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2021 |
default: return; |
2755
ba133949851b
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2753
diff
changeset
|
2022 |
} |
5006
390d6334da67
(svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents:
5005
diff
changeset
|
2023 |
e->we.keypress.cont = false; |
2755
ba133949851b
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2753
diff
changeset
|
2024 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2025 |
|
0 | 2026 |
case WE_PLACE_OBJ: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2027 |
_place_proc(e->we.place.tile); |
0 | 2028 |
} break; |
2029 |
||
2030 |
case WE_ABORT_PLACE_OBJ: { |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
2031 |
RaiseWindowWidget(w, 25); |
0 | 2032 |
SetWindowDirty(w); |
2033 |
} break; |
|
2034 |
||
2035 |
case WE_MOUSELOOP: |
|
4748
8a928d86a56c
(svn r6660) -Fix(r6631): Prevent the fast-foward button to toggle up and down when pressing shift.
belugas
parents:
4719
diff
changeset
|
2036 |
if (IsWindowWidgetLowered(w, 0) != !!_pause) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
2037 |
ToggleWidgetLoweredState(w, 0); |
24 | 2038 |
SetWindowDirty(w); |
2039 |
} |
|
2040 |
||
4748
8a928d86a56c
(svn r6660) -Fix(r6631): Prevent the fast-foward button to toggle up and down when pressing shift.
belugas
parents:
4719
diff
changeset
|
2041 |
if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
2042 |
ToggleWidgetLoweredState(w, 1); |
0 | 2043 |
SetWindowDirty(w); |
2044 |
} |
|
2045 |
break; |
|
2046 |
||
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2047 |
case WE_MESSAGE: |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2048 |
HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10); |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2049 |
break; |
0 | 2050 |
} |
2051 |
} |
|
2052 |
||
2053 |
static const WindowDesc _toolb_scen_desc = { |
|
2054 |
0, 0, 640, 22, |
|
2055 |
WC_MAIN_TOOLBAR,0, |
|
2056 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
2057 |
_toolb_scen_widgets, |
|
2058 |
ScenEditToolbarWndProc |
|
2059 |
}; |
|
2060 |
||
2061 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
|
2062 |
||
2063 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2432
diff
changeset
|
2064 |
static bool DrawScrollingStatusText(const NewsItem *ni, int pos) |
0 | 2065 |
{ |
1336
69391734ce23
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
2066 |
char buf[512]; |
0 | 2067 |
StringID str; |
1329 | 2068 |
const char *s; |
2069 |
char *d; |
|
0 | 2070 |
DrawPixelInfo tmp_dpi, *old_dpi; |
2071 |
int x; |
|
1329 | 2072 |
char buffer[256]; |
0 | 2073 |
|
2074 |
if (ni->display_mode == 3) { |
|
2075 |
str = _get_news_string_callback[ni->callback](ni); |
|
2076 |
} else { |
|
2077 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2078 |
str = ni->string_id; |
0 | 2079 |
} |
2080 |
||
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4907
diff
changeset
|
2081 |
GetString(buf, str, lastof(buf)); |
0 | 2082 |
|
1336
69391734ce23
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
2083 |
s = buf; |
0 | 2084 |
d = buffer; |
2085 |
||
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
2086 |
for (;;) { |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
2087 |
WChar c = Utf8Consume(&s); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
2088 |
if (c == 0) { |
2639 | 2089 |
*d = '\0'; |
0 | 2090 |
break; |
2091 |
} else if (*s == 0x0D) { |
|
2092 |
d[0] = d[1] = d[2] = d[3] = ' '; |
|
2639 | 2093 |
d += 4; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
2094 |
} else if (IsPrintable(c)) { |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
2095 |
d += Utf8Encode(d, c); |
0 | 2096 |
} |
2097 |
} |
|
2098 |
||
4429
b4eb6d97996f
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4349
diff
changeset
|
2099 |
if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, 358, 11)) return true; |
0 | 2100 |
|
2101 |
old_dpi = _cur_dpi; |
|
2102 |
_cur_dpi = &tmp_dpi; |
|
2103 |
||
2104 |
x = DoDrawString(buffer, pos, 0, 13); |
|
2105 |
_cur_dpi = old_dpi; |
|
2106 |
||
2107 |
return x > 0; |
|
2108 |
} |
|
2109 |
||
410 | 2110 |
static void StatusBarWndProc(Window *w, WindowEvent *e) |
0 | 2111 |
{ |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2112 |
switch (e->event) { |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2113 |
case WE_PAINT: { |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
2114 |
const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player); |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2115 |
|
0 | 2116 |
DrawWindowWidgets(w); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2117 |
SetDParam(0, _date); |
2639 | 2118 |
DrawStringCentered( |
2119 |
70, 1, (_pause || _patches.status_long_date) ? STR_00AF : STR_00AE, 0 |
|
2120 |
); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2121 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2122 |
if (p != NULL) { |
0 | 2123 |
// Draw player money |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2124 |
SetDParam64(0, p->money64); |
0 | 2125 |
DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0); |
2126 |
} |
|
2127 |
||
2128 |
// Draw status bar |
|
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2129 |
if (w->message.msg) { // true when saving is active |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2130 |
DrawStringCentered(320, 1, STR_SAVING_GAME, 0); |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2131 |
} else if (_do_autosave) { |
2951 | 2132 |
DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0); |
0 | 2133 |
} else if (_pause) { |
2951 | 2134 |
DrawStringCentered(320, 1, STR_0319_PAUSED, 0); |
0 | 2135 |
} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { |
2136 |
// Draw the scrolling news text |
|
2137 |
if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1)) |
|
2138 |
WP(w,def_d).data_1 = -1280; |
|
2139 |
} else { |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2140 |
if (p != NULL) { |
0 | 2141 |
// This is the default text |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2142 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2143 |
SetDParam(1, p->name_2); |
2951 | 2144 |
DrawStringCentered(320, 1, STR_02BA, 0); |
0 | 2145 |
} |
2146 |
} |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2147 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2148 |
if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, 489, 2); |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2149 |
} break; |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2150 |
|
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2151 |
case WE_MESSAGE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2152 |
w->message.msg = e->we.message.msg; |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2153 |
SetWindowDirty(w); |
0 | 2154 |
break; |
2155 |
||
2156 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2157 |
switch (e->we.click.widget) { |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2158 |
case 1: ShowLastNewsMessage(); break; |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
2159 |
case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break; |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
2160 |
default: ResetObjectToPlace(); |
0 | 2161 |
} |
2162 |
break; |
|
2163 |
||
2164 |
case WE_TICK: { |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2165 |
if (_pause) return; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2166 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2167 |
if (WP(w, def_d).data_1 > -1280) { /* Scrolling text */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2168 |
WP(w, def_d).data_1 -= 2; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2169 |
InvalidateWidget(w, 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2170 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2171 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2172 |
if (WP(w, def_d).data_2 > 0) { /* Red blot to show there are new unread newsmessages */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2173 |
WP(w, def_d).data_2 -= 2; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2174 |
} else if (WP(w, def_d).data_2 < 0) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2175 |
WP(w, def_d).data_2 = 0; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2176 |
InvalidateWidget(w, 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2177 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
2178 |
|
0 | 2179 |
break; |
2180 |
} |
|
2181 |
} |
|
2182 |
} |
|
2183 |
||
2184 |
static const Widget _main_status_widgets[] = { |
|
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
2185 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 139, 0, 11, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
2186 |
{ WWT_PUSHBTN, RESIZE_NONE, 14, 140, 499, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
2187 |
{ WWT_PUSHBTN, RESIZE_NONE, 14, 500, 639, 0, 11, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
2188 |
{ WIDGETS_END}, |
0 | 2189 |
}; |
2190 |
||
2191 |
static WindowDesc _main_status_desc = { |
|
2192 |
WDP_CENTER, 0, 640, 12, |
|
2193 |
WC_STATUS_BAR,0, |
|
2194 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
2195 |
_main_status_widgets, |
|
2196 |
StatusBarWndProc |
|
2197 |
}; |
|
2198 |
||
1772
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
2199 |
extern void UpdateAllStationVirtCoord(void); |
0 | 2200 |
|
4171 | 2201 |
static void MainWindowWndProc(Window *w, WindowEvent *e) |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
2202 |
{ |
0 | 2203 |
int off_x; |
2204 |
||
2952 | 2205 |
switch (e->event) { |
0 | 2206 |
case WE_PAINT: |
2207 |
DrawWindowViewport(w); |
|
2208 |
if (_game_mode == GM_MENU) { |
|
581
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2209 |
off_x = _screen.width / 2; |
0 | 2210 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2211 |
DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2212 |
DrawSprite(SPR_OTTD_P, PAL_NONE, off_x - 86, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2213 |
DrawSprite(SPR_OTTD_E, PAL_NONE, off_x - 53, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2214 |
DrawSprite(SPR_OTTD_N, PAL_NONE, off_x - 22, 50); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2215 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2216 |
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 34, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2217 |
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2218 |
DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50); |
670
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2219 |
|
581
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2220 |
/* |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2221 |
DrawSprite(SPR_OTTD_R, off_x + 119, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2222 |
DrawSprite(SPR_OTTD_A, off_x + 148, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2223 |
DrawSprite(SPR_OTTD_N, off_x + 181, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2224 |
DrawSprite(SPR_OTTD_S, off_x + 215, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2225 |
DrawSprite(SPR_OTTD_P, off_x + 246, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2226 |
DrawSprite(SPR_OTTD_O, off_x + 275, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2227 |
DrawSprite(SPR_OTTD_R, off_x + 307, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2228 |
DrawSprite(SPR_OTTD_T, off_x + 337, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2229 |
|
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2230 |
DrawSprite(SPR_OTTD_T, off_x + 390, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2231 |
DrawSprite(SPR_OTTD_Y, off_x + 417, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2232 |
DrawSprite(SPR_OTTD_C, off_x + 447, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2233 |
DrawSprite(SPR_OTTD_O, off_x + 478, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2234 |
DrawSprite(SPR_OTTD_O, off_x + 509, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2235 |
DrawSprite(SPR_OTTD_N, off_x + 541, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
2236 |
*/ |
0 | 2237 |
} |
2238 |
break; |
|
2239 |
||
2240 |
case WE_KEYPRESS: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2241 |
switch (e->we.keypress.keycode) { |
2639 | 2242 |
case 'Q' | WKC_CTRL: |
2243 |
case 'Q' | WKC_META: |
|
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
2244 |
HandleExitGameRequest(); |
2639 | 2245 |
break; |
2501
8d13d08b9232
(svn r3027) -Feature: [OSX] command+q now works in main menu (Tobin)
bjarni
parents:
2469
diff
changeset
|
2246 |
} |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2247 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2248 |
/* Disable all key shortcuts, except quit shortcuts when |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2249 |
* generating the world, otherwise they create threading |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2250 |
* problem during the generating, resulting in random |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2251 |
* assertions that are hard to trigger and debug */ |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2252 |
if (IsGeneratingWorld()) break; |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2253 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2254 |
if (e->we.keypress.keycode == WKC_BACKQUOTE) { |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2255 |
IConsoleSwitch(); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2256 |
e->we.keypress.cont = false; |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2257 |
break; |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2258 |
} |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2259 |
|
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
2260 |
if (_game_mode == GM_MENU) break; |
0 | 2261 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2262 |
switch (e->we.keypress.keycode) { |
2639 | 2263 |
case 'C': |
2264 |
case 'Z': { |
|
2265 |
Point pt = GetTileBelowCursor(); |
|
2266 |
if (pt.x != -1) { |
|
2267 |
ScrollMainWindowTo(pt.x, pt.y); |
|
5046
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
2268 |
if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w); |
2639 | 2269 |
} |
2270 |
break; |
|
0 | 2271 |
} |
2639 | 2272 |
|
2273 |
case WKC_ESC: ResetObjectToPlace(); break; |
|
2274 |
case WKC_DELETE: DeleteNonVitalWindows(); break; |
|
2275 |
case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break; |
|
2276 |
case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break; |
|
2277 |
||
1772
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
2278 |
#if defined(_DEBUG) |
2639 | 2279 |
case '0' | WKC_ALT: /* Crash the game */ |
2280 |
*(byte*)0 = 0; |
|
2281 |
break; |
|
2282 |
||
2283 |
case '1' | WKC_ALT: /* Gimme money */ |
|
2284 |
/* Server can not cheat in advertise mode either! */ |
|
2285 |
if (!_networking || !_network_server || !_network_advertise) |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2286 |
DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT); |
2639 | 2287 |
break; |
2288 |
||
2289 |
case '2' | WKC_ALT: /* Update the coordinates of all station signs */ |
|
2290 |
UpdateAllStationVirtCoord(); |
|
2291 |
break; |
|
2292 |
#endif |
|
2293 |
||
2294 |
case 'X': |
|
2295 |
_display_opt ^= DO_TRANS_BUILDINGS; |
|
2296 |
MarkWholeScreenDirty(); |
|
2297 |
break; |
|
0 | 2298 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2299 |
#ifdef ENABLE_NETWORK |
5107
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2300 |
case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2301 |
if (_networking) { |
5107
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2302 |
const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index); |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2303 |
bool teamchat = false; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2304 |
|
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2305 |
/* Only players actually playing can speak to team. Eg spectators cannot */ |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2306 |
if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2307 |
const NetworkClientInfo *ci; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2308 |
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2309 |
if (ci->client_playas == cio->client_playas && ci != cio) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2310 |
teamchat = true; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2311 |
break; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2312 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2313 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2314 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2315 |
|
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
2316 |
ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas); |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2317 |
} |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2318 |
break; |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2319 |
|
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2320 |
case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players |
2639 | 2321 |
if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
2322 |
break; |
|
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2323 |
|
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2324 |
case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2325 |
if (_networking) { |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2326 |
const NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index); |
4907 | 2327 |
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, ci->client_playas); |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2328 |
} |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
2329 |
break; |
1772
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
2330 |
#endif |
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
2331 |
|
2639 | 2332 |
default: return; |
0 | 2333 |
} |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2334 |
e->we.keypress.cont = false; |
0 | 2335 |
break; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2336 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2337 |
case WE_SCROLL: { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2338 |
ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y); |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2339 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2340 |
if (vp == NULL) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2341 |
_cursor.fix_at = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2342 |
_scrolling_viewport = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2343 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2344 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2345 |
WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2346 |
WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
2347 |
} break; |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
2348 |
|
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
2349 |
case WE_MOUSEWHEEL: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
2350 |
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
2351 |
break; |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2352 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2353 |
case WE_MESSAGE: |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2354 |
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */ |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2355 |
SendWindowMessage(WC_MAIN_TOOLBAR, 0, e->we.message.msg, e->we.message.wparam, e->we.message.lparam); |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
2356 |
break; |
0 | 2357 |
} |
2358 |
} |
|
2359 |
||
2360 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2361 |
void ShowSelectGameWindow(void); |
0 | 2362 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2363 |
void SetupColorsAndInitialWindow(void) |
0 | 2364 |
{ |
2639 | 2365 |
uint i; |
0 | 2366 |
Window *w; |
5413 | 2367 |
int width, height; |
0 | 2368 |
|
2639 | 2369 |
for (i = 0; i != 16; i++) { |
4171 | 2370 |
const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i); |
1357 | 2371 |
|
0 | 2372 |
assert(b); |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4434
diff
changeset
|
2373 |
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i])); |
0 | 2374 |
} |
2375 |
||
2376 |
width = _screen.width; |
|
2377 |
height = _screen.height; |
|
2378 |
||
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2379 |
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2380 |
AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2381 |
|
0 | 2382 |
// XXX: these are not done |
2639 | 2383 |
switch (_game_mode) { |
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2384 |
default: NOT_REACHED(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2385 |
case GM_MENU: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2386 |
ShowSelectGameWindow(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2387 |
break; |
0 | 2388 |
|
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2389 |
case GM_NORMAL: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2390 |
case GM_EDITOR: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2391 |
ShowVitalWindows(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
2392 |
break; |
0 | 2393 |
} |
2394 |
} |
|
2395 |
||
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2396 |
void ShowVitalWindows(void) |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2397 |
{ |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2398 |
Window *w; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2399 |
|
5048
b784951def0a
(svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents:
5046
diff
changeset
|
2400 |
w = AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc); |
b784951def0a
(svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents:
5046
diff
changeset
|
2401 |
DoZoomInOutWindow(ZOOM_NONE, w); |
b784951def0a
(svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents:
5046
diff
changeset
|
2402 |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2403 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2404 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
2405 |
SetWindowWidgetDisabledState(w, 0, _networking && !_network_server); // if not server, disable pause button |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
2406 |
SetWindowWidgetDisabledState(w, 1, _networking); // if networking, disable fast-forward button |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1015
diff
changeset
|
2407 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
2408 |
/* 'w' is for sure a WC_MAIN_TOOLBAR */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
2409 |
PositionMainToolbar(w); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
2410 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
2411 |
/* Status bad only for normal games */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
2412 |
if (_game_mode == GM_EDITOR) return; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2413 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2414 |
_main_status_desc.top = _screen.height - 12; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2415 |
w = AllocateWindowDesc(&_main_status_desc); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2416 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2417 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2418 |
WP(w,def_d).data_1 = -1280; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2419 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
2420 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2421 |
void GameSizeChanged(void) |
0 | 2422 |
{ |
2429
5e5b66fb8420
(svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents:
2361
diff
changeset
|
2423 |
_cur_resolution[0] = _screen.width; |
5e5b66fb8420
(svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents:
2361
diff
changeset
|
2424 |
_cur_resolution[1] = _screen.height; |
0 | 2425 |
RelocateAllWindows(_screen.width, _screen.height); |
2426 |
ScreenSizeChanged(); |
|
2427 |
MarkWholeScreenDirty(); |
|
2428 |
} |
|
3622
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
2429 |
|
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
2430 |
void InitializeMainGui(void) |
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
2431 |
{ |
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
2432 |
/* Clean old GUI values */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2433 |
_last_built_railtype = RAILTYPE_RAIL; |
3622
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
2434 |
} |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
2435 |
|
5237
4fce3ea379c2
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
5235
diff
changeset
|
2436 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
2437 |