src/main_gui.cpp
author rubidium
Wed, 26 Dec 2007 13:50:40 +0000
changeset 8140 0d0d8c94f84b
parent 8139 4e91c448c409
child 8144 65cec0877b78
permissions -rw-r--r--
(svn r11702) -Codechange: move all date related stuff to date*.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
     3
/** @file main_gui.cpp */
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1885
diff changeset
     6
#include "openttd.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
     7
#include "heightmap.h"
2292
0b9d6e4ea0e6 (svn r2816) Forgot an Id tag and an #include
tron
parents: 2261
diff changeset
     8
#include "currency.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
     9
#include "spritecache.h"
2466
1aa260b43faa (svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents: 2436
diff changeset
    10
#include "station.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"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    14
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    15
#include "window_func.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    16
#include "textbuf_gui.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "player.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    19
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
#include "news.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
#include "town.h"
130
b593afdae262 (svn r131) Completely changed hotkey from tab to backquote (not working in Windows yet)
dominik
parents: 126
diff changeset
    22
#include "vehicle.h"
126
152df0cc4ac2 (svn r127) New feature: ingame console. (sign_de)
dominik
parents: 116
diff changeset
    23
#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
    24
#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
    25
#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
    26
#include "signs.h"
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1500
diff changeset
    27
#include "waypoint.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    28
#include "variables.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2652
diff changeset
    29
#include "train.h"
6857
60130753e595 (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 6847
diff changeset
    30
#include "roadveh.h"
7202
dc312a87f450 (svn r10480) -Fix: Don't allow building lighthouses and transmitters under bridges in the scenario editor, or during world generation.
maedhros
parents: 7127
diff changeset
    31
#include "bridge_map.h"
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3248
diff changeset
    32
#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
    33
#include "string.h"
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
    34
#include "screenshot.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    35
#include "genworld.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    36
#include "settings.h"
4668
f7256d0e7682 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    37
#include "vehicle_gui.h"
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
    38
#include "transparency_gui.h"
5237
4fce3ea379c2 (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 5235
diff changeset
    39
#include "newgrf_config.h"
8111
02d19f43eea6 (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8108
diff changeset
    40
#include "rail_gui.h"
02d19f43eea6 (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8108
diff changeset
    41
#include "road_gui.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    42
#include "date_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8123
diff changeset
    43
#include "functions.h"
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    44
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
    45
#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
    46
#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
    47
#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
    48
#include "network/network_gui.h"
4942
7fb6c39eb421 (svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents: 4938
diff changeset
    49
#include "industry.h"
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
    50
#include "transparency.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8111
diff changeset
    51
#include "strings_func.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    52
#include "zoom_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    54
static int _rename_id = 1;
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    55
static int _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
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
    58
RailType _last_built_railtype;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
    59
RoadType _last_built_roadtype;
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
    60
static int _scengen_town_size = 1; // depress medium-sized towns per default
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    62
extern void GenerateIndustries();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    63
extern bool GenerateTowns();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
7643
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
    65
bool _draw_bounding_boxes = false;
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
    66
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    67
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    68
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    69
{
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    70
#ifdef ENABLE_NETWORK
7657
2b55af55cc51 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents: 7643
diff changeset
    71
	if (!success || !_patches.give_money) return;
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    72
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    73
	char msg[20];
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    74
	/* Inform the player of this action */
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    75
	snprintf(msg, sizeof(msg), "%d", p1);
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    76
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    77
	if (!_network_server) {
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    78
		SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg);
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    79
	} else {
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    80
		NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, NETWORK_SERVER_INDEX);
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    81
	}
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    82
#endif /* ENABLE_NETWORK */
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    83
}
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    84
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    85
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
    86
{
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    87
	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
    88
	_cmd_text = str;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    89
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
    90
	switch (_rename_what) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
    91
	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
    92
		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
    93
		DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
		break;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    95
#ifdef ENABLE_NETWORK
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
    96
	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
    97
		const Player *p = GetPlayer(_current_player);
7505
55e7acbf7a69 (svn r11020) -Fix [FS#1174]: One could not give money when (s)he had too much money or rather: when casting the amount of money to an int32 becomes negative.
rubidium
parents: 7480
diff changeset
    98
		Money money = min(p->player_money - p->current_loan, (Money)(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
    99
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
   100
		uint32 money_c = Clamp(ClampToI32(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
   101
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   102
		/* Give 'id' the money, and substract it from ourself */
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6953
diff changeset
   103
		DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6486
diff changeset
   104
	} break;
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   105
#endif /* ENABLE_NETWORK */
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   106
		default: NOT_REACHED();
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   107
	}
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   108
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   109
	_rename_id = _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
1070
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   112
/**
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   113
 * This code is shared for the majority of the pushbuttons.
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   114
 * 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
   115
 *
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   116
 * @param w Window which called the function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   117
 * @param widget ID of the widget (=button) that called this function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   118
 * @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
   119
 * @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
   120
 * @param placeproc Procedure which will be called when someone clicks on the map
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   121
 * @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
   122
 */
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
   123
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   125
	if (w->IsWidgetDisabled(widget)) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
2621
2bacc2e9c68f (svn r3159) Remove the read-only variable _no_button_sound
tron
parents: 2615
diff changeset
   127
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   130
	if (w->IsWidgetLowered(widget)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
   135
	SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   136
	w->LowerWidget(widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	_place_proc = placeproc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   142
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   144
	if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
static void ToolbarPauseClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
{
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   150
	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
   151
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
   152
	if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
static void ToolbarFastForwardClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	_fast_forward ^= true;
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   158
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   162
static void MenuClickSettings(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   164
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   165
		case 0: ShowGameOptions();      return;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   166
		case 1: ShowGameDifficulty();   return;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   167
		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
   168
		case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig);   return;
7015
0e76fdaed37c (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7002
diff changeset
   169
		case 4: ShowTransparencyToolbar(); break;
0e76fdaed37c (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7002
diff changeset
   170
7932
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   171
		case  6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES);    break;
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   172
		case  7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   173
		case  8: ToggleBit(_display_opt, DO_SHOW_SIGNS);         break;
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   174
		case  9: ToggleBit(_display_opt, DO_WAYPOINTS);          break;
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   175
		case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION);     break;
6c3d71e8a129 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 7931
diff changeset
   176
		case 11: ToggleBit(_display_opt, DO_FULL_DETAIL);        break;
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   177
		case 12:
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   178
			ToggleTransparency(TO_TREES);
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   179
			ToggleTransparency(TO_HOUSES);
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   180
			break;
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   181
		case 13: ToggleTransparency(TO_SIGNS);                   break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
	}
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   183
	MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   186
static void MenuClickSaveLoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	if (_game_mode == GM_EDITOR) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   189
		switch (index) {
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   190
			case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO);  break;
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   191
			case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO);  break;
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   192
			case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   193
			case 3: AskExitToGameMenu();                    break;
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   194
			case 5: HandleExitGameRequest();                break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
	} else {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   197
		switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   198
			case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   199
			case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   200
			case 2: AskExitToGameMenu();               break;
4548
6165e12570bf (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
   201
			case 3: HandleExitGameRequest();           break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   206
static void MenuClickMap(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   208
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   209
		case 0: ShowSmallMap();            break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   210
		case 1: ShowExtraViewPortWindow(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   211
		case 2: ShowSignList();            break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   215
static void MenuClickTown(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	ShowTownDirectory();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   220
static void MenuClickScenMap(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   222
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   223
		case 0: ShowSmallMap();            break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   224
		case 1: ShowExtraViewPortWindow(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   225
		case 2: ShowSignList();            break;
7125
ef3b4aaf994f (svn r10398) -Fix (r10271): transparency menu option wasn't moved properly in the scenario editor
peter1138
parents: 7086
diff changeset
   226
		case 3: ShowTownDirectory();       break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   230
static void MenuClickSubsidies(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
	ShowSubsidiesList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   235
static void MenuClickStations(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   237
	ShowPlayerStations((PlayerID)index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   240
static void MenuClickFinances(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   242
	ShowPlayerFinances((PlayerID)index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   245
static void MenuClickCompany(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
{
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   247
	if (_networking && index == 0) {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   248
		ShowClientList();
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   249
	} else {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   250
		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
   251
		ShowPlayerCompany((PlayerID)index);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   252
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   254
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   255
static void MenuClickGraphs(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   257
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   258
		case 0: ShowOperatingProfitGraph();    break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   259
		case 1: ShowIncomeGraph();             break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   260
		case 2: ShowDeliveredCargoGraph();     break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   261
		case 3: ShowPerformanceHistoryGraph(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   262
		case 4: ShowCompanyValueGraph();       break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   263
		case 5: ShowCargoPaymentRates();       break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   267
static void MenuClickLeague(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   269
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   270
		case 0: ShowCompanyLeagueTable();      break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   271
		case 1: ShowPerformanceRatingDetail(); break;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 74
diff changeset
   272
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   275
static void MenuClickIndustry(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   277
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   278
		case 0: ShowIndustryDirectory();   break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   279
		case 1: ShowBuildIndustryWindow(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   283
static void MenuClickShowTrains(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
   285
	ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   288
static void MenuClickShowRoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
   290
	ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   293
static void MenuClickShowShips(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
   295
	ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   298
static void MenuClickShowAir(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
{
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
   300
	ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   303
static void MenuClickBuildRail(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   305
	_last_built_railtype = (RailType)index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	ShowBuildRailToolbar(_last_built_railtype, -1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   309
static void MenuClickBuildRoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
{
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   311
	_last_built_roadtype = (RoadType)index;
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   312
	ShowBuildRoadToolbar(_last_built_roadtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   315
static void MenuClickBuildWater(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	ShowBuildDocksToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   320
static void MenuClickBuildAir(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	ShowBuildAirToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   325
#ifdef ENABLE_NETWORK
4830
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4824
diff changeset
   326
void ShowNetworkGiveMoneyWindow(PlayerID player)
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   327
{
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   328
	_rename_id = player;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   329
	_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
   330
	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
   331
}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   332
#endif /* ENABLE_NETWORK */
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   333
2116
23031555ff54 (svn r2626) static, const, misc.
tron
parents: 2092
diff changeset
   334
void ShowRenameWaypointWindow(const Waypoint *wp)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
{
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1500
diff changeset
   336
	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
   337
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   338
	/* 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
   339
	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
   340
		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
   341
			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
   342
		return;
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   343
	}
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   344
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	_rename_id = id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	_rename_what = 1;
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   347
	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
   348
	ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   351
static void SelectSignTool()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   353
	if (_cursor.sprite == SPR_CURSOR_SIGN) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		ResetObjectToPlace();
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   355
	} else {
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
   356
		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
		_place_proc = PlaceProc_Sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   361
static void MenuClickForest(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   363
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   364
		case 0: ShowTerraformToolbar();  break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   365
		case 1: ShowBuildTreesToolbar(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   366
		case 2: SelectSignTool();        break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   370
static void MenuClickMusicWindow(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	ShowMusicWindow();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   375
static void MenuClickNewspaper(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   377
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   378
		case 0: ShowLastNewsMessage(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   379
		case 1: ShowMessageOptions();  break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   380
		case 2: ShowMessageHistory();  break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   384
static void MenuClickSmallScreenshot()
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   385
{
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   386
	SetScreenshotType(SC_VIEWPORT);
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   387
}
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   388
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   389
static void MenuClickWorldScreenshot()
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   390
{
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   391
	SetScreenshotType(SC_WORLD);
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   392
}
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   393
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   394
static void MenuClickHelp(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
{
2432
c48585a8b05f (svn r2958) - Feature: [ 1258971 ] Menu option to toggle console. Mainly for MacOS's or PDA's. (toholio)
Darkvater
parents: 2430
diff changeset
   396
	switch (index) {
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   397
		case 0: PlaceLandBlockInfo();       break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   398
		case 2: IConsoleSwitch();           break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   399
		case 3: MenuClickSmallScreenshot(); break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   400
		case 4: MenuClickWorldScreenshot(); break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   401
		case 5: ShowAboutWindow();          break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   405
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   406
typedef void MenuClickedProc(int index);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   407
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
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
   409
	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
   410
	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
   411
	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
   412
	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
   413
	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
   414
	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
   415
	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
   416
	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
   417
	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
   418
	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
   419
	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
   420
	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
   421
	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
   422
	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
   423
	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
   424
	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
   425
	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
   426
	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
   427
	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
   428
	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
   429
	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
   430
	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
   431
	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
   432
	MenuClickForest,      /* 23 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	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
   434
	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
   435
	MenuClickHelp,        /* 26 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
static void MenuWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   440
	switch (e->event) {
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   441
		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
   442
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
	case WE_PAINT: {
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   444
		int x, y;
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   445
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   446
		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
   447
		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
   448
		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
   449
		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
   450
		byte dis = WP(w, menu_d).disabled_items;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
		x = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
		y = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   457
		for (; count != 0; count--, string++, sel--) {
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
   458
			TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK;
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   459
			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
   460
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
   461
			if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   462
			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
   463
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
			chk >>= 1;
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   466
			dis >>= 1;
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   467
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	case WE_DESTROY: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   472
			v->RaiseWidget(WP(w, menu_d).main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
			SetWindowDirty(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   476
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	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
   478
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
		int action_id;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   480
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
		if (index < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   484
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   485
				index = WP(w, menu_d).sel_index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   488
		action_id = WP(w, menu_d).action_id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
		DeleteWindow(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   490
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   491
		if (index >= 0) {
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   492
			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
   493
			_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
   494
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   495
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
		}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   498
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
	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
   500
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   502
		if (index == -1 || index == WP(w, menu_d).sel_index) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   504
		WP(w, menu_d).sel_index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   511
/* 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
   512
 * 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
   513
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
   514
{    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
   515
{ WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 815
diff changeset
   519
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
   520
{    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
   521
{ WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
static int GetPlayerIndexFromMenu(int index)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	if (index >= 0) {
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   528
		const Player *p;
2630
7206058a7e82 (svn r3172) static, const
tron
parents: 2621
diff changeset
   529
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
		FOR_ALL_PLAYERS(p) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   531
			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
   532
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
	return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
static void UpdatePlayerMenuHeight(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
{
4824
c49e6ffcb89a (svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents: 4822
diff changeset
   539
	byte num = ActivePlayerCount();
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   540
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   541
	/* Increase one to fit in PlayerList in the menu when in network */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   542
	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
   543
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   544
	if (WP(w, menu_d).item_count != num) {
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   545
		WP(w, menu_d).item_count = num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
		num = num * 10 + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
		w->height = num;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 815
diff changeset
   549
		w->widget[0].bottom = w->widget[0].top + num - 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
static void PlayerMenuWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   556
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
		int x,y;
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
   559
		byte sel;
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
   560
		TextColour color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
		uint16 chk;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
		UpdatePlayerMenuHeight(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
		x = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
		y = 1;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   569
		sel = WP(w, menu_d).sel_index;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   570
		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
   571
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   572
		/* 9 = playerlist */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   573
		if (_networking && WP(w, menu_d).main_button == 9) {
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   574
			if (sel == 0) {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   575
				GfxFillRect(x, y, x + 238, y + 9, 0);
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   576
			}
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
   577
			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   578
			y += 10;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   579
			sel--;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   580
		}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   581
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
		FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
			if (p->is_active) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
				if (p->index == sel) {
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   585
					GfxFillRect(x, y, x + 238, y + 9, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
				}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   587
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   588
				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
   589
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
   590
				SetDParam(0, p->index);
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
   591
				SetDParam(1, p->index);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   592
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
   593
				color = (p->index == sel) ? TC_WHITE : TC_BLACK;
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
   594
				if (chk&1) color = TC_GREY;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   595
				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
   596
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
				y += 10;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   598
			}
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   599
			chk >>= 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   601
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
	case WE_DESTROY: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
		Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   607
		v->RaiseWidget(WP(w, menu_d).main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
		SetWindowDirty(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   611
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
	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
   613
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   614
		int action_id = WP(w, menu_d).action_id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   616
		/* We have a new entry at the top of the list of menu 9 when networking
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   617
		 *  so keep that in count */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   618
		if (_networking && WP(w, menu_d).main_button == 9) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   619
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   620
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   621
			index = GetPlayerIndexFromMenu(index);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   622
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   623
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
		if (index < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   626
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   627
				index = WP(w, menu_d).sel_index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
		DeleteWindow(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   631
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
		if (index >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
			assert(index >= 0 && index < 30);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
			_menu_clicked_procs[action_id](index);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
	case WE_POPUPMENU_OVER: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		int index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
		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
   641
		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
   642
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   643
		/* We have a new entry at the top of the list of menu 9 when networking
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   644
		 * so keep that in count */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   645
		if (_networking && WP(w, menu_d).main_button == 9) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   646
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   647
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   648
			index = GetPlayerIndexFromMenu(index);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   649
		}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   650
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   651
		if (index == -1 || index == WP(w, menu_d).sel_index) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   653
		WP(w, menu_d).sel_index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   660
/** 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
   661
 * 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
   662
 * @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
   663
 * @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
   664
 * @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
   665
static int GetStringListMaxWidth(StringID base_string, byte count)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
{
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   667
	char buffer[512];
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   668
	int width, max_width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   669
	byte i;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   670
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   671
	max_width = 0;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   672
	for (i = 0; i != count; i++) {
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4907
diff changeset
   673
		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
   674
		width = GetStringBoundingBox(buffer).width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   675
		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
   676
	}
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   677
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   678
	return max_width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   679
}
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   680
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   681
/** 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
   682
 * 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
   683
 * 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
   684
 * 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
   685
 * 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
   686
 * 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
   687
 * 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
   688
 * @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
   689
 * 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
   690
 * @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
   691
 * 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
   692
 * 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
   693
 * 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
   694
 * 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
   695
 * as button. So<br>
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   696
 * 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
   697
 * 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
   698
 * @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
   699
 * 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
   700
 * @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
   701
 * @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
   702
 * @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
   703
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
   704
{
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   705
	int width;
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   706
	int x = w->widget[GB(parent_button, 0, 8)].left;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   708
	assert(disabled_mask == 0 || item_count <= 8);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   709
	w->LowerWidget(parent_button);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
   710
	w->InvalidateWidget(parent_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   714
	/* 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
   715
	 * 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
   716
	 * 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
   717
	 * 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
   718
	 * 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
   719
	width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
   720
	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
   721
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   722
	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
   723
	w->widget[0].bottom = item_count * 10 + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   725
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   726
	WP(w, menu_d).item_count = item_count;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   727
	WP(w, menu_d).sel_index = 0;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   728
	WP(w, menu_d).main_button = GB(parent_button, 0, 8);
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   729
	WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   730
	WP(w, menu_d).string_id = base_string;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   731
	WP(w, menu_d).checked_items = 0;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   732
	WP(w, menu_d).disabled_items = disabled_mask;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
	_popup_menu_active = true;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   735
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   736
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
	return w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   740
static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   742
	int x = w->widget[main_button].left + w->left;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   743
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   744
	w->LowerWidget(main_button);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
   745
	w->InvalidateWidget(main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   750
	WP(w, menu_d).item_count = 0;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   751
	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
   752
	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
   753
		if (_local_player != PLAYER_SPECTATOR) {
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   754
			WP(w, menu_d).sel_index++;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   755
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   756
			/* Select client list by default for spectators */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   757
			WP(w, menu_d).sel_index = 0;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   758
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   759
	}
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   760
	WP(w, menu_d).action_id = main_button;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   761
	WP(w, menu_d).main_button = main_button;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   762
	WP(w, menu_d).checked_items = gray;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   763
	WP(w, menu_d).disabled_items = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
	_popup_menu_active = true;
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   765
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
	return w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
static void ToolbarSaveClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   771
	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
static void ToolbarMapClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
{
7015
0e76fdaed37c (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7002
diff changeset
   776
	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   779
static void ToolbarTownClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   780
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   781
	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   782
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   783
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   784
static void ToolbarSubsidiesClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   786
	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
static void ToolbarStationsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   791
	PopupMainPlayerToolbMenu(w, 7, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
static void ToolbarMoneyClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   796
	PopupMainPlayerToolbMenu(w, 8, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   797
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
static void ToolbarPlayersClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   800
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   801
	PopupMainPlayerToolbMenu(w, 9, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   803
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
static void ToolbarGraphsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   806
	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
static void ToolbarLeagueClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   811
	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
static void ToolbarIndustryClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   816
	/* 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
   817
	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
static void ToolbarTrainClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   822
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   824
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   825
	FOR_ALL_VEHICLES(v) {
7929
6c9b25842b0f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   826
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   827
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   828
	PopupMainPlayerToolbMenu(w, 13, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   829
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   830
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
static void ToolbarRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   833
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   835
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   836
	FOR_ALL_VEHICLES(v) {
7929
6c9b25842b0f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   837
		if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   838
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   839
	PopupMainPlayerToolbMenu(w, 14, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   841
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
static void ToolbarShipClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   844
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   846
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   847
	FOR_ALL_VEHICLES(v) {
7929
6c9b25842b0f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   848
		if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   849
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   850
	PopupMainPlayerToolbMenu(w, 15, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
static void ToolbarAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   855
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   857
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   858
	FOR_ALL_VEHICLES(v) {
7929
6c9b25842b0f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   859
		if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   860
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   861
	PopupMainPlayerToolbMenu(w, 16, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
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
   864
/* 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
   865
/* 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
   866
bool DoZoomInOutWindow(int how, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
	ViewPort *vp;
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   869
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   870
	assert(w != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   871
	vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   873
	switch (how) {
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   874
		case ZOOM_IN:
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
   875
			if (vp->zoom == ZOOM_LVL_MIN) return false;
8095
f834186120af (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents: 8082
diff changeset
   876
			vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   877
			vp->virtual_width >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   878
			vp->virtual_height >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   879
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   880
			WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   881
			WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   882
			WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   883
			WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   884
			break;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   885
		case ZOOM_OUT:
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
   886
			if (vp->zoom == ZOOM_LVL_MAX) return false;
8095
f834186120af (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents: 8082
diff changeset
   887
			vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   888
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   889
			WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   890
			WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   891
			WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   892
			WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   893
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   894
			vp->virtual_width <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   895
			vp->virtual_height <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   896
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   897
	}
5214
62a0325b53c7 (svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents: 5118
diff changeset
   898
	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
   899
		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
   900
		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
   901
	}
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   902
	SetWindowDirty(w);
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   903
	/* 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
   904
	SendWindowMessageClass(w->window_class, how, w->window_number, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
static void ToolbarZoomInClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
{
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
   910
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
   911
		w->HandleButtonClick(17);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   912
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   913
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   914
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
static void ToolbarZoomOutClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
{
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
   918
	if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
   919
		w->HandleButtonClick(18);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   920
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   923
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   924
static void ToolbarBuildRailClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   926
	const Player *p = GetPlayer(_local_player);
6685
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   927
	Window *w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   928
	WP(w2, menu_d).sel_index = _last_built_railtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   929
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   931
static void ToolbarBuildRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
{
6685
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   933
	const Player *p = GetPlayer(_local_player);
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   934
	/* The standard road button is *always* available */
7857
6572278b5822 (svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents: 7854
diff changeset
   935
	Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   936
	WP(w2, menu_d).sel_index = _last_built_roadtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   939
static void ToolbarBuildWaterClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   941
	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   943
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   944
static void ToolbarBuildAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   946
	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   948
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
static void ToolbarForestClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   950
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   951
	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
static void ToolbarMusicClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   955
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   956
	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   958
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   959
static void ToolbarNewspaperClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   960
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   961
	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   962
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   963
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   964
static void ToolbarHelpClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   965
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   966
	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   967
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   968
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   969
static void ToolbarOptionsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
{
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   971
	uint16 x = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
7015
0e76fdaed37c (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7002
diff changeset
   973
	w = PopupMainToolbMenu(w, 2, STR_02C3_GAME_OPTIONS, 14, 0);
0e76fdaed37c (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7002
diff changeset
   974
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   975
	if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES))    SetBit(x,  6);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   976
	if (HasBit(_display_opt, DO_SHOW_STATION_NAMES)) SetBit(x,  7);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   977
	if (HasBit(_display_opt, DO_SHOW_SIGNS))         SetBit(x,  8);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   978
	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   979
	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   980
	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   981
	if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12);
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   982
	if (IsTransparencySet(TO_SIGNS))                     SetBit(x, 13);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   983
	WP(w, menu_d).checked_items = x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   984
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   985
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   986
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   987
static void ToolbarScenSaveOrLoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   988
{
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   989
	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   992
static void ToolbarScenDateBackward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
{
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   994
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   995
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
   996
		w->HandleButtonClick(6);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   997
		SetWindowDirty(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   998
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
   999
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1000
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1001
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1002
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1003
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1004
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
static void ToolbarScenDateForward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
{
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1007
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1009
		w->HandleButtonClick(7);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1010
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1011
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
  1012
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1013
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1015
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1016
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
static void ToolbarScenMapTownDir(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
  1020
	/* Scenario editor button, *hack*hack* use different button to activate */
7125
ef3b4aaf994f (svn r10398) -Fix (r10271): transparency menu option wasn't moved properly in the scenario editor
peter1138
parents: 7086
diff changeset
  1021
	PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1022
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1023
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1024
static void ToolbarScenZoomIn(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1025
{
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
  1026
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1027
		w->HandleButtonClick(9);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1028
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1029
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1032
static void ToolbarScenZoomOut(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
{
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
  1034
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1035
		w->HandleButtonClick(10);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1036
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1037
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1038
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1039
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1040
void ZoomInOrOutToCursorWindow(bool in, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1042
	ViewPort *vp;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1043
	Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1044
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1045
	assert(w != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1046
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1047
	vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1048
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1049
	if (_game_mode != GM_MENU) {
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
  1050
		if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1051
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
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
  1053
		pt = GetTileZoomCenterWindow(in,w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
		if (pt.x != -1) {
6730
9311a208f8f7 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 6691
diff changeset
  1055
			ScrollWindowTo(pt.x, pt.y, w, true);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
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
  1057
			DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1059
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1060
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1061
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
  1062
/**
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
  1063
 * 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
  1064
 * 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
  1065
 * tiles in the selection to that height.
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1066
 * @todo : Incorporate into game itself to allow for ingame raising/lowering of
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1067
 *         larger chunks at the same time OR remove altogether, as we have 'level 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
  1068
 * @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
  1069
 * @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
  1070
 */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1071
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1072
{
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1073
	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
  1074
	uint h;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1075
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
  1076
	_generating_world = true; // used to create green terraformed land
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1077
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1078
	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
  1079
		StringID msg =
0cec126ca9a9 (svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents: 3134
diff changeset
  1080
			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
  1081
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7505
diff changeset
  1082
		DoCommandP(tile, SLOPE_N, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_MSG(msg));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1083
	} else {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1084
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1085
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1086
		assert(_terraform_size != 0);
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1087
		/* check out for map overflows */
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1088
		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
  1089
		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
  1090
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1091
		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
  1092
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1093
		if (mode != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1094
			/* 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
  1095
			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
  1096
			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
  1097
				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
  1098
			} END_TILE_LOOP(tile2, sizex, sizey, tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1099
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
			/* Lower land */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
			h = 0;
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1102
			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
  1103
				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
  1104
			} END_TILE_LOOP(tile2, sizex, sizey, tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1105
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1106
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1107
		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
  1108
			if (TileHeight(tile2) == h) {
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7505
diff changeset
  1109
				DoCommandP(tile2, SLOPE_N, (uint32)mode, NULL, CMD_TERRAFORM_LAND);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
			}
1697
95e9612b851d (svn r2201) - Fix: Crash in scenario-editor with terraforming out-of-map bounds.
Darkvater
parents: 1688
diff changeset
  1111
		} END_TILE_LOOP(tile2, sizex, sizey, tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1112
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1114
	_generating_world = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1116
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1117
static void PlaceProc_RaiseBigLand(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1118
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1119
	CommonRaiseLowerBigLand(tile, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1120
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1121
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1122
static void PlaceProc_LowerBigLand(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1123
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1124
	CommonRaiseLowerBigLand(tile, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1125
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1126
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1127
static void PlaceProc_RockyArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1128
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1129
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_ROCKS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1130
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1131
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1132
static void PlaceProc_LightHouse(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
{
7202
dc312a87f450 (svn r10480) -Fix: Don't allow building lighthouses and transmitters under bridges in the scenario editor, or during world generation.
maedhros
parents: 7127
diff changeset
  1134
	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
		return;
2652
733e6877ccb1 (svn r3194) Don't use FindLandscapeHeightByTile() when it's overkill
tron
parents: 2643
diff changeset
  1136
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3248
diff changeset
  1138
	MakeLighthouse(tile);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3248
diff changeset
  1139
	MarkTileDirtyByTile(tile);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1140
	SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1141
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1142
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1143
static void PlaceProc_Transmitter(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1144
{
7202
dc312a87f450 (svn r10480) -Fix: Don't allow building lighthouses and transmitters under bridges in the scenario editor, or during world generation.
maedhros
parents: 7127
diff changeset
  1145
	if (!IsTileType(tile, MP_CLEAR) || IsSteepSlope(GetTileSlope(tile, NULL)) || IsBridgeAbove(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1146
		return;
2652
733e6877ccb1 (svn r3194) Don't use FindLandscapeHeightByTile() when it's overkill
tron
parents: 2643
diff changeset
  1147
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1148
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3248
diff changeset
  1149
	MakeTransmitter(tile);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3248
diff changeset
  1150
	MarkTileDirtyByTile(tile);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1151
	SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1152
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1153
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
  1154
static void PlaceProc_DesertArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1155
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1156
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_DESERT);
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
  1157
}
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
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
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
  1160
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1161
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_WATER);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1162
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1163
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
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
  1165
{  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
  1166
{   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
  1167
{ WWT_STICKYBOX,   RESIZE_NONE,     7,   170,   181,     0,    13, STR_NULL,                  STR_STICKY_BUTTON},
5890
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1168
{     WWT_PANEL,   RESIZE_NONE,     7,     0,   181,    14,   102, 0x0,                       STR_NULL},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1169
{    WWT_IMGBTN,   RESIZE_NONE,    14,     2,    23,    16,    37, SPR_IMG_DYNAMITE,          STR_018D_DEMOLISH_BUILDINGS_ETC},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1170
{    WWT_IMGBTN,   RESIZE_NONE,    14,    24,    45,    16,    37, SPR_IMG_TERRAFORM_DOWN,    STR_018E_LOWER_A_CORNER_OF_LAND},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1171
{    WWT_IMGBTN,   RESIZE_NONE,    14,    46,    67,    16,    37, SPR_IMG_TERRAFORM_UP,      STR_018F_RAISE_A_CORNER_OF_LAND},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1172
{    WWT_IMGBTN,   RESIZE_NONE,    14,    68,    89,    16,    37, SPR_IMG_LEVEL_LAND,        STR_LEVEL_LAND_TOOLTIP},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1173
{    WWT_IMGBTN,   RESIZE_NONE,    14,    90,   111,    16,    37, SPR_IMG_BUILD_CANAL,       STR_CREATE_LAKE},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1174
{    WWT_IMGBTN,   RESIZE_NONE,    14,   112,   134,    16,    37, SPR_IMG_ROCKS,             STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1175
{    WWT_IMGBTN,   RESIZE_NONE,    14,   135,   157,    16,    37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1176
{    WWT_IMGBTN,   RESIZE_NONE,    14,   158,   179,    16,    37, SPR_IMG_TRANSMITTER,       STR_028E_PLACE_TRANSMITTER},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1177
{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    45,    56, SPR_ARROW_UP,              STR_0228_INCREASE_SIZE_OF_LAND_AREA},
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1178
{    WWT_IMGBTN,   RESIZE_NONE,    14,   139,   150,    58,    69, SPR_ARROW_DOWN,            STR_0229_DECREASE_SIZE_OF_LAND_AREA},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
  1179
{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    76,    87, STR_SE_NEW_WORLD,          STR_022A_GENERATE_RANDOM_LAND},
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
  1180
{   WWT_TEXTBTN,   RESIZE_NONE,    14,    24,   157,    89,   100, STR_022B_RESET_LANDSCAPE,  STR_RESET_LANDSCAPE_TOOLTIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 168
diff changeset
  1181
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1182
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
static const int8 _multi_terraform_coords[][2] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1185
	{  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
  1186
	{  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
  1187
	{ -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
  1188
	{-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
  1189
	{-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
  1190
	{-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
  1191
	{-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
  1192
	{-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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1193
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1194
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1195
/**
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1196
 * @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1197
 * and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1198
 */
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
  1199
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
  1200
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1201
	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
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
  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_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
  1205
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1206
	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
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
  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_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
  1210
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1211
	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
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
  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_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
  1215
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1216
	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
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
  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 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
  1220
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1221
	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
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
  1222
}
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
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
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
  1225
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1226
	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
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
  1227
}
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
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
  1230
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1231
	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
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
  1232
}
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
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
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
  1235
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1236
	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
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
  1237
}
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
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
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
  1240
	'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
  1241
	'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
  1242
	'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
  1243
	'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
  1244
	'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
  1245
	'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
  1246
	'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
  1247
	'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
  1248
};
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
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
  1250
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
  1251
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
  1252
	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
  1253
	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
  1254
	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
  1255
	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
  1256
	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
  1257
	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
  1258
	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
  1259
	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
  1260
};
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
  1261
5890
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1262
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1263
/** Callback function for the scenario editor 'reset landscape' confirmation window
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6449
diff changeset
  1264
 * @param w Window unused
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6449
diff changeset
  1265
 * @param confirmed boolean value, true when yes was clicked, false otherwise */
5890
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1266
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1267
{
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1268
	if (confirmed) {
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1269
		Player *p;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1270
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1271
		/* Set generating_world to true to get instant-green grass after removing
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1272
		 * player property. */
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1273
		_generating_world = true;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1274
		/* Delete all players */
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1275
		FOR_ALL_PLAYERS(p) {
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1276
			if (p->is_active) {
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1277
				ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1278
				p->is_active = false;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1279
			}
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1280
		}
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1281
		_generating_world = false;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1282
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1283
		/* Delete all stations owned by a player */
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1284
		Station *st;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1285
		FOR_ALL_STATIONS(st) {
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1286
			if (IsValidPlayer(st->owner)) delete st;
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1287
		}
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1288
	}
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1289
}
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1290
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1291
static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1292
{
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
	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
  1294
	case WE_CREATE:
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1295
		/* XXX - lighthouse button is widget 10!! Don't forget when changing */
6357
f0f5e7d1713c (svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents: 6259
diff changeset
  1296
		w->widget[10].tooltips = (_opt.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
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
  1297
		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
  1298
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1299
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1300
		DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1301
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1302
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1303
			int n = _terraform_size * _terraform_size;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1304
			const int8 *coords = &_multi_terraform_coords[0][0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1305
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1306
			assert(n != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1307
			do {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  1308
				DrawSprite(SPR_WHITE_POINT, PAL_NONE, 77 + coords[0], 55 + coords[1]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1309
				coords += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1310
			} while (--n);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1311
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1312
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1313
		if (w->IsWidgetLowered(5) || w->IsWidgetLowered(6)) // change area-size if raise/lower corner is selected
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1314
			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
  1315
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
  1316
		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
  1317
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_KEYPRESS: {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1319
		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
  1320
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
		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
  1322
			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
  1323
				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
  1324
				_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
  1325
				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
  1326
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1327
		}
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
  1328
	} 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
  1329
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1330
	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
  1331
		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
  1332
		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
  1333
			_editor_terraform_button_proc[e->we.click.widget - 4](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1334
			break;
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1335
		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
  1336
			int size = (e->we.click.widget == 12) ? 1 : -1;
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1337
			w->HandleButtonClick(e->we.click.widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1338
			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
  1339
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7932
diff changeset
  1340
			if (!IsInsideMM(size, 1, 8 + 1)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1341
			_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
  1342
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1343
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1344
			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
  1345
		} break;
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1346
		case 14: // gen random land
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1347
			w->HandleButtonClick(14);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1348
			ShowCreateScenario();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1349
			break;
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1350
		case 15: // Reset landscape
5890
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1351
			ShowQuery(
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1352
			  STR_022C_RESET_LANDSCAPE,
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1353
			  STR_RESET_LANDSCAPE_CONFIRMATION_TEXT,
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1354
			  NULL,
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1355
			  ResetLandscapeConfirmationCallback);
a5ba89d7f278 (svn r8507) -Codechange/Feature: Don't remove player-owned property on-load in the scenario editor. Add a button to the landscape window to do this.
Darkvater
parents: 5750
diff changeset
  1356
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1357
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
		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
  1359
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1360
	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
  1361
		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
  1362
		for (i = 0; i < w->widget_count; i++) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1363
			if (w->IsWidgetLowered(i)) {
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1364
				w->RaiseWidget(i);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1365
				w->InvalidateWidget(i);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1366
			}
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1367
			if (i == 3) i = 11;
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1368
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1369
		break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1370
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1371
	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
  1372
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1373
		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
  1374
	case WE_PLACE_DRAG:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
  1375
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
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
		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
  1377
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1378
	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
  1379
		if (e->we.place.pt.x != -1) {
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1380
			switch (e->we.place.select_proc) {
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1381
				case DDSP_CREATE_ROCKS:
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1382
				case DDSP_CREATE_DESERT:
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1383
				case DDSP_CREATE_WATER:
6672
b688fe8f73b9 (svn r9903) -Fix (r9901): Make the demolish and level land tools work in the scenario editor again.
maedhros
parents: 6670
diff changeset
  1384
				case DDSP_LEVEL_AREA:
b688fe8f73b9 (svn r9903) -Fix (r9901): Make the demolish and level land tools work in the scenario editor again.
maedhros
parents: 6670
diff changeset
  1385
				case DDSP_DEMOLISH_AREA:
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1386
					GUIPlaceProcDragXY(e);
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1387
					break;
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
  1388
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1389
		}
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
  1390
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1392
	case WE_ABORT_PLACE_OBJ:
8032
f35fba9bacb0 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents: 8028
diff changeset
  1393
		w->RaiseButtons();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1394
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1395
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1396
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1397
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1399
static const WindowDesc _scen_edit_land_gen_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7311
diff changeset
  1400
	WDP_AUTO, WDP_AUTO, 182, 103, 182, 103,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1401
	WC_SCEN_LAND_GEN, WC_NONE,
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
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1403
	_scen_edit_land_gen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1404
	ScenEditLandGenWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1405
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1406
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  1407
static inline void ShowEditorTerraformToolBar()
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
  1408
{
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
  1409
	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
  1410
}
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
  1411
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1412
static void ToolbarScenGenLand(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1414
	w->HandleButtonClick(11);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1415
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1416
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
  1417
	ShowEditorTerraformToolBar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1418
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1419
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1420
void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1421
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1422
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1423
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1424
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1425
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1426
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1427
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1428
static void PlaceProc_Town(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1429
{
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1430
	uint32 size = min(_scengen_town_size, (int)TSM_CITY);
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1431
	uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1432
	DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1433
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1434
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1435
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1436
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
  1437
{   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
  1438
{    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
  1439
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   148,   159,     0,    13, 0x0,                      STR_STICKY_BUTTON},
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1440
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   159,    14,    94, 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
  1441
{    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
  1442
{    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
  1443
{    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
  1444
{    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
  1445
{    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
  1446
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   106,   157,    68,    79, STR_02A3_LARGE,           STR_02A4_SELECT_TOWN_SIZE},
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1447
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   157,    81,    92, STR_SCENARIO_EDITOR_CITY, 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
  1448
{      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
  1449
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1450
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1452
static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1453
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1454
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1455
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1456
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1457
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1458
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
  1459
	case WE_CREATE:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1460
		w->LowerWidget(_scengen_town_size + 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
  1461
		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
  1462
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1463
	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
  1464
		switch (e->we.click.widget) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1465
		case 4: // new town
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1466
			HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1467
			break;
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1468
		case 5: {// random town
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1469
			Town *t;
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1470
			uint size = min(_scengen_town_size, (int)TSM_CITY);
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1471
			TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1472
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1473
			w->HandleButtonClick(5);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1474
			_generating_world = true;
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1475
			t = CreateRandomTown(20, mode, size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1476
			_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
  1477
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
  1478
			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
  1479
				ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1480
			} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1481
				ScrollMainWindowToTile(t->xy);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1482
			}
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
  1483
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1484
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1485
		}
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1486
		case 6: {// many random towns
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1487
			w->HandleButtonClick(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
  1488
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1489
			_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
  1490
			if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1491
			_generating_world = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1492
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1493
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1494
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1495
		case 7: case 8: case 9: case 10:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1496
			w->RaiseWidget(_scengen_town_size + 7);
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1497
			_scengen_town_size = e->we.click.widget - 7;
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1498
			w->LowerWidget(_scengen_town_size + 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1499
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1500
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1501
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1502
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1503
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1504
	case WE_TIMEOUT:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1505
		w->RaiseWidget(5);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1506
		w->RaiseWidget(6);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1507
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1508
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1509
	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
  1510
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1511
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1512
	case WE_ABORT_PLACE_OBJ:
8032
f35fba9bacb0 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents: 8028
diff changeset
  1513
		w->RaiseButtons();
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1514
		w->LowerWidget(_scengen_town_size + 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1515
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1516
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1517
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1518
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1519
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1520
static const WindowDesc _scen_edit_town_gen_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7311
diff changeset
  1521
	WDP_AUTO, WDP_AUTO, 160, 95, 160, 95,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1522
	WC_SCEN_TOWN_GEN, WC_NONE,
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
  1523
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1524
	_scen_edit_town_gen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1525
	ScenEditTownGenWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1526
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1527
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1528
static void ToolbarScenGenTown(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1529
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1530
	w->HandleButtonClick(12);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1531
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1532
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1533
	AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1534
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1535
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1536
static void ToolbarScenGenIndustry(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1537
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1538
	w->HandleButtonClick(13);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1539
	SndPlayFx(SND_15_BEEP);
7218
8e73038b7586 (svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
belugas
parents: 7202
diff changeset
  1540
	ShowBuildIndustryWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1541
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1542
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1543
static void ToolbarScenBuildRoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1544
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1545
	w->HandleButtonClick(14);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1546
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1547
	ShowBuildRoadScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1548
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1549
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1550
static void ToolbarScenPlantTrees(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1551
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1552
	w->HandleButtonClick(15);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1553
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1554
	ShowBuildTreesScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1555
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1556
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1557
static void ToolbarScenPlaceSign(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1558
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1559
	w->HandleButtonClick(16);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1560
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1561
	SelectSignTool();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1562
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1564
static void ToolbarBtn_NULL(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1565
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1566
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1567
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1568
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1569
typedef void ToolbarButtonProc(Window *w);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1570
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1571
static ToolbarButtonProc * const _toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1572
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1575
	ToolbarSaveClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1576
	ToolbarMapClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1577
	ToolbarTownClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1578
	ToolbarSubsidiesClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1579
	ToolbarStationsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1580
	ToolbarMoneyClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1581
	ToolbarPlayersClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1582
	ToolbarGraphsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1583
	ToolbarLeagueClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1584
	ToolbarIndustryClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1585
	ToolbarTrainClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1586
	ToolbarRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1587
	ToolbarShipClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1588
	ToolbarAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1589
	ToolbarZoomInClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1590
	ToolbarZoomOutClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1591
	ToolbarBuildRailClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1592
	ToolbarBuildRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1593
	ToolbarBuildWaterClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1594
	ToolbarBuildAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1595
	ToolbarForestClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1596
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1597
	ToolbarNewspaperClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1598
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1599
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1600
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1601
static void MainToolbarWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1602
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  1603
	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
  1604
	case WE_PAINT:
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1605
		/* Draw brown-red toolbar bg. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1606
		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
  1607
		GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1608
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1609
		/* If spectator, disable all construction buttons
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1610
		 * ie : Build road, rail, ships, airports and landscaping
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1611
		 * Since enabled state is the default, just disable when needed */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1612
		w->SetWidgetsDisabledState(_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
  1613
		/* disable company list drop downs, if there are no companies */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1614
		w->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1615
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1616
		w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1617
		w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7058
diff changeset
  1618
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1619
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1620
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1621
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1622
	case WE_CLICK: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1623
		if (_game_mode != GM_MENU && !w->IsWidgetDisabled(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
  1624
			_toolbar_button_procs[e->we.click.widget](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1625
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1626
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1627
	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
  1628
		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
  1629
		case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1630
		case WKC_F2: ShowGameOptions(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1631
		case WKC_F3: MenuClickSaveLoad(0); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1632
		case WKC_F4: ShowSmallMap(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1633
		case WKC_F5: ShowTownDirectory(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1634
		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
  1635
		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
  1636
		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
  1637
		case WKC_F9: ShowPlayerCompany(_local_player); break;
7030
a79f5991623f (svn r10294) -Fix [FS#914]: WKC_PAUSE didn't work in SE (+ some cosmetic) (Smoovious)
truelight
parents: 7015
diff changeset
  1638
		case WKC_F10: ShowOperatingProfitGraph(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1639
		case WKC_F11: ShowCompanyLeagueTable(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1640
		case WKC_F12: ShowBuildIndustryWindow(); break;
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
  1641
		case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_TRAIN); break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
  1642
		case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_ROAD); break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
  1643
		case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_SHIP); break;
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6247
diff changeset
  1644
		case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_AIRCRAFT); break;
7311
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1645
		case WKC_NUM_PLUS: // Fall through
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1646
		case WKC_EQUALS: // Fall through
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1647
		case WKC_SHIFT | WKC_EQUALS: // Fall through
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1648
		case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
7311
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1649
		case WKC_NUM_MINUS: // Fall through
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1650
		case WKC_MINUS: // Fall through
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1651
		case WKC_SHIFT | WKC_MINUS: // Fall through
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1652
		case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7058
diff changeset
  1653
		case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
  1654
		case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1655
		case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7058
diff changeset
  1656
		case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1657
		case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1658
		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
  1659
		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
  1660
		case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1661
		case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
7311
fde7a4d92a39 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7310
diff changeset
  1662
		case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
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
  1663
		case 'L': ShowTerraformToolbar(); break;
7310
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7266
diff changeset
  1664
		case 'M': ShowSmallMap(); break;
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7266
diff changeset
  1665
		case 'V': ShowExtraViewPortWindow(); break;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1397
diff changeset
  1666
		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
  1667
		}
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  1668
		e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1669
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1670
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1671
	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
  1672
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1673
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1674
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1675
	case WE_ABORT_PLACE_OBJ: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1676
		w->RaiseWidget(25);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1677
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1678
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1679
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1680
	case WE_MOUSELOOP:
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1681
		if (w->IsWidgetLowered(0) != !!_pause_game) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1682
			w->ToggleWidgetLoweredState(0);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1683
			w->InvalidateWidget(0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1684
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1685
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1686
		if (w->IsWidgetLowered(1) != !!_fast_forward) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1687
			w->ToggleWidgetLoweredState(1);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1688
			w->InvalidateWidget(1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1689
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1690
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1691
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1692
	case WE_RESIZE: {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1693
		/* There are 27 buttons plus some spacings if the space allows it */
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1694
		uint button_width;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1695
		uint spacing;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1696
		if (w->width >= 27 * 22) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1697
			button_width = 22;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1698
			spacing = w->width - (27 * button_width);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1699
		} else {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1700
			button_width = w->width / 27;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1701
			spacing = 0;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1702
		}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1703
		uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1704
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1705
		for (uint i = 0, x = 0, j = 0; i < 27; i++) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1706
			if (extra_spacing_at[j] == i) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1707
				j++;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1708
				uint add = spacing / (lengthof(extra_spacing_at) - j);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1709
				spacing -= add;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1710
				x += add;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1711
			}
7361
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1712
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1713
			w->widget[i].left = x;
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1714
			x += (spacing != 0) ? button_width : (w->width - x) / (27 - i);
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1715
			w->widget[i].right = x - 1;
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1716
		}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1717
	} break;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1718
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1719
	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
  1720
		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
  1721
		for (i = 2; i < w->widget_count; i++) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1722
			if (w->IsWidgetLowered(i)) {
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1723
				w->RaiseWidget(i);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1724
				w->InvalidateWidget(i);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1725
			}
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1726
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1727
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1728
	}
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1729
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1730
		case WE_MESSAGE:
7248
16d259bc2ad0 (svn r10548) -Fix [FS#1020]: don't segfault when you quit in the end-of-the-game screen
truelight
parents: 7218
diff changeset
  1731
			if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1732
			break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1733
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1734
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1735
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1736
static const Widget _toolb_normal_widgets[] = {
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1737
{     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1738
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1739
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1740
{   WWT_IMGBTN_2,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1741
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1742
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1743
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1744
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1745
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1746
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1747
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1748
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1749
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1750
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1751
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1752
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1753
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1754
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1755
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1756
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1757
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1758
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1759
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1760
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1761
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1762
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1763
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1764
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1765
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_LANDSCAPING,     STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1766
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1767
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1768
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1769
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     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
  1770
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1771
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1772
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1773
static const WindowDesc _toolb_normal_desc = {
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1774
	0, 0, 0, 22, 640, 22,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1775
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1776
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1777
	_toolb_normal_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1778
	MainToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1779
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1780
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1781
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1782
static const Widget _toolb_scen_widgets[] = {
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1783
{  WWT_IMGBTN, RESIZE_LEFT, 14,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1784
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1785
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1786
{WWT_IMGBTN_2, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1787
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1788
{   WWT_PANEL, RESIZE_NONE, 14,   0,   0,  0, 21, 0x0,                 STR_NULL},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1789
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1790
{   WWT_PANEL, RESIZE_NONE, 14,   0, 129,  0, 21, 0x0,                 STR_NULL},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1791
{  WWT_IMGBTN, RESIZE_NONE, 14,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1792
{  WWT_IMGBTN, RESIZE_NONE, 14, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1793
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1794
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1795
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1796
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1797
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1798
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1799
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1800
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1801
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1802
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1803
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1804
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1805
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1806
{   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
  1807
{   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
  1808
{   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
  1809
{   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
  1810
{   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
  1811
{   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
  1812
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1813
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1814
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1815
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  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
  1816
{WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1817
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1818
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1819
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1820
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1821
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1822
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1823
	ToolbarScenSaveOrLoad,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1824
	ToolbarBtn_NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1825
	ToolbarBtn_NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1826
	ToolbarScenDateBackward,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1827
	ToolbarScenDateForward,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1828
	ToolbarScenMapTownDir,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1829
	ToolbarScenZoomIn,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1830
	ToolbarScenZoomOut,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1831
	ToolbarScenGenLand,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1832
	ToolbarScenGenTown,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1833
	ToolbarScenGenIndustry,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1834
	ToolbarScenBuildRoad,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1835
	ToolbarScenPlantTrees,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1836
	ToolbarScenPlaceSign,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1837
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1838
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1839
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1840
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1841
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1842
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1843
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1844
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1845
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1846
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1847
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1848
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1849
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1850
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  1851
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1852
	case WE_PAINT:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1853
		w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1854
		w->SetWidgetDisabledState(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
  1855
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  1856
		/* Draw brown-red toolbar bg. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1857
		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
  1858
		GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1859
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1860
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1861
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1862
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  1863
		DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1864
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1865
		/* We hide this panel when the toolbar space gets too small */
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1866
		if (w->widget[4].left != w->widget[4].right) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  1867
			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  1868
			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1869
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1870
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1871
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1872
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1873
	case WE_CLICK: {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1874
		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
  1875
		_scen_toolbar_button_procs[e->we.click.widget](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1876
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1877
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1878
	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
  1879
		switch (e->we.keypress.keycode) {
7030
a79f5991623f (svn r10294) -Fix [FS#914]: WKC_PAUSE didn't work in SE (+ some cosmetic) (Smoovious)
truelight
parents: 7015
diff changeset
  1880
			case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
5006
390d6334da67 (svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents: 5005
diff changeset
  1881
			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
  1882
			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
  1883
			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
  1884
			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
  1885
			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
  1886
			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
  1887
			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
  1888
			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
  1889
			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
  1890
			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
  1891
			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
  1892
			case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
8056
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1893
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1894
			/* those following are all fall through */
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1895
			case WKC_NUM_PLUS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1896
			case WKC_EQUALS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1897
			case WKC_SHIFT | WKC_EQUALS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1898
			case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1899
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1900
			/* those following are all fall through */
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1901
			case WKC_NUM_MINUS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1902
			case WKC_MINUS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1903
			case WKC_SHIFT | WKC_MINUS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1904
			case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1905
5006
390d6334da67 (svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents: 5005
diff changeset
  1906
			case 'L': ShowEditorTerraformToolBar(); break;
8056
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1907
			case 'M': ShowSmallMap(); break;
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1908
			case 'V': ShowExtraViewPortWindow(); break;
5006
390d6334da67 (svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents: 5005
diff changeset
  1909
			default: return;
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1910
		}
5006
390d6334da67 (svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents: 5005
diff changeset
  1911
		e->we.keypress.cont = false;
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1912
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1913
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1914
	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
  1915
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1916
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1917
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1918
	case WE_ABORT_PLACE_OBJ: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1919
		w->RaiseWidget(25);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1920
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1921
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1922
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1923
	case WE_RESIZE: {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1924
		/* There are 15 buttons plus some spacings if the space allows it.
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1925
		 * Furthermore there are two panels of which one is non-essential
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1926
		 * and that one can be removed is the space is too small. */
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1927
		uint buttons_width;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1928
		uint spacing;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1929
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1930
		static int normal_min_width = (15 * 22) + (2 * 130);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1931
		static int one_less_panel_min_width = (15 * 22) + 130;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1932
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1933
		if (w->width >= one_less_panel_min_width) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1934
			buttons_width = 15 * 22;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1935
			spacing = w->width - ((w->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1936
		} else {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1937
			buttons_width = w->width - 130;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1938
			spacing = 0;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1939
		}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1940
		uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 16, 0 };
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1941
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1942
		/* Yes, it defines about 27 widgets for this toolbar */
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1943
		for (uint i = 0, x = 0, j = 0, b = 0; i < 27; i++) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1944
			switch (i) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1945
				case 4:
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1946
					w->widget[i].left = x;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1947
					if (w->width < normal_min_width) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1948
						w->widget[i].right = x;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1949
						j++;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1950
						continue;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1951
					}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1952
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1953
					x += 130;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1954
					w->widget[i].right = x - 1;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1955
					break;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1956
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1957
				case 5: {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1958
					int offset = x - w->widget[i].left;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1959
					w->widget[i + 1].left  += offset;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1960
					w->widget[i + 1].right += offset;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1961
					w->widget[i + 2].left  += offset;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1962
					w->widget[i + 2].right += offset;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1963
					w->widget[i].left = x;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1964
					x += 130;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1965
					w->widget[i].right = x - 1;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1966
					i += 2;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1967
				} break;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1968
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1969
				default:
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1970
					if (w->widget[i].bottom == 0) continue;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1971
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1972
					w->widget[i].left = x;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1973
					x += buttons_width / (15 - b);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1974
					w->widget[i].right = x - 1;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1975
					buttons_width -= buttons_width / (15 - b);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1976
					b++;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1977
					break;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1978
			}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1979
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1980
			if (extra_spacing_at[j] == i) {
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1981
				j++;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1982
				uint add = spacing / (lengthof(extra_spacing_at) - j);
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1983
				spacing -= add;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1984
				x += add;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1985
			}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1986
		}
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1987
	} break;
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  1988
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1989
	case WE_MOUSELOOP:
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1990
		if (w->IsWidgetLowered(0) != !!_pause_game) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1991
			w->ToggleWidgetLoweredState(0);
24
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1992
			SetWindowDirty(w);
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1993
		}
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1994
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1995
		if (w->IsWidgetLowered(1) != !!_fast_forward) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1996
			w->ToggleWidgetLoweredState(1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1997
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1998
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1999
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2000
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  2001
		case WE_MESSAGE:
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  2002
			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
  2003
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2004
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2005
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2006
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2007
static const WindowDesc _toolb_scen_desc = {
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  2008
	0, 0, 130, 22, 640, 22,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  2009
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2010
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2011
	_toolb_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2012
	ScenEditToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2013
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2014
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2015
extern GetNewsStringCallbackProc * const _get_news_string_callback[];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2016
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2017
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2018
static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2019
{
1336
69391734ce23 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
  2020
	char buf[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2021
	StringID str;
1329
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  2022
	const char *s;
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  2023
	char *d;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2024
	DrawPixelInfo tmp_dpi, *old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2025
	int x;
1329
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  2026
	char buffer[256];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2027
7854
8232d650df92 (svn r11404) -Codechange: remove 2 magical numbers
belugas
parents: 7849
diff changeset
  2028
	if (ni->display_mode == NM_CALLBACK) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2029
		str = _get_news_string_callback[ni->callback](ni);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2030
	} else {
7266
b16e67e992b4 (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7248
diff changeset
  2031
		CopyInDParam(0, ni->params, lengthof(ni->params));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  2032
		str = ni->string_id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2033
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2034
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4907
diff changeset
  2035
	GetString(buf, str, lastof(buf));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2036
1336
69391734ce23 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
  2037
	s = buf;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2038
	d = buffer;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2039
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
  2040
	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
  2041
		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
  2042
		if (c == 0) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2043
			*d = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2044
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2045
		} else if (*s == 0x0D) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2046
			d[0] = d[1] = d[2] = d[3] = ' ';
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2047
			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
  2048
		} 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
  2049
			d += Utf8Encode(d, c);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2050
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2051
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2052
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2053
	if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2054
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2055
	old_dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2056
	_cur_dpi = &tmp_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2057
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2058
	x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2059
	_cur_dpi = old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2060
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2061
	return x > 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2062
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2063
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
  2064
static void StatusBarWndProc(Window *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2065
{
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
  2066
	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
  2067
	case WE_PAINT: {
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  2068
		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
  2069
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2070
		DrawWindowWidgets(w);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  2071
		SetDParam(0, _date);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2072
		DrawStringCentered(
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2073
			70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2074
		);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  2075
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2076
		if (p != NULL) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2077
			/* Draw player money */
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
  2078
			SetDParam(0, p->player_money);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2079
			DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2080
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2081
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2082
		/* 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
  2083
		if (w->message.msg) { // true when saving is active
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2084
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING);
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
  2085
		} else if (_do_autosave) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2086
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
  2087
		} else if (_pause_game) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2088
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
  2089
		} else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2090
			/* Draw the scrolling news text */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
  2091
			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
  2092
				WP(w, def_d).data_1 = -1280;
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2093
				if (p != NULL) {
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2094
					/* This is the default text */
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2095
					SetDParam(0, p->index);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2096
					DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2097
				}
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2098
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2099
		} else {
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2100
			if (p != NULL) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2101
				/* This is the default text */
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
  2102
				SetDParam(0, p->index);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2103
				DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2104
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2105
		}
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
  2106
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  2107
		if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 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
  2108
	} 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
  2109
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
  2110
	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
  2111
		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
  2112
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2113
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2115
	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
  2116
		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
  2117
			case 1: ShowLastNewsMessage(); break;
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  2118
			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
  2119
			default: ResetObjectToPlace();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2120
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2121
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2122
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2123
	case WE_TICK: {
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
  2124
		if (_pause_game) return;
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
  2125
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2126
		if (WP(w, def_d).data_1 > -1280) { // Scrolling text
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
  2127
			WP(w, def_d).data_1 -= 2;
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  2128
			w->InvalidateWidget(1);
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
  2129
		}
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
  2130
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2131
		if (WP(w, def_d).data_2 > 0) { // Red blot to show there are new unread newsmessages
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
  2132
			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
  2133
		} 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
  2134
			WP(w, def_d).data_2 = 0;
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  2135
			w->InvalidateWidget(1);
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
  2136
		}
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
  2137
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2138
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2139
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2140
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2141
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2143
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
  2144
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   139,     0,    11, 0x0, STR_NULL},
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  2145
{    WWT_PUSHBTN,   RESIZE_RIGHT,   14,   140,   179,     0,    11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS},
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  2146
{    WWT_PUSHBTN,   RESIZE_LR,      14,   180,   319,     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
  2147
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2148
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2149
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2150
static WindowDesc _main_status_desc = {
7360
113ae4cb8aad (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7359
diff changeset
  2151
	WDP_CENTER, 0, 320, 12, 640, 12,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  2152
	WC_STATUS_BAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2153
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2154
	_main_status_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2155
	StatusBarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2156
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2157
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2158
extern void UpdateAllStationVirtCoord();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2159
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  2160
static void MainWindowWndProc(Window *w, WindowEvent *e)
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4013
diff changeset
  2161
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2162
	int off_x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2163
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  2164
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2165
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2166
		DrawWindowViewport(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2167
		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
  2168
			off_x = _screen.width / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2169
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  2170
			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
  2171
			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
  2172
			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
  2173
			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
  2174
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  2175
			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
  2176
			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
  2177
			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
  2178
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
  2179
			/*
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
  2180
			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
  2181
			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
  2182
			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
  2183
			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
  2184
			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
  2185
			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
  2186
			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
  2187
			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
  2188
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
  2189
			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
  2190
			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
  2191
			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
  2192
			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
  2193
			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
  2194
			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
  2195
			*/
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2196
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2197
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2198
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2199
	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
  2200
		switch (e->we.keypress.keycode) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2201
			case 'Q' | WKC_CTRL:
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2202
			case 'Q' | WKC_META:
4548
6165e12570bf (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
  2203
				HandleExitGameRequest();
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2204
				break;
2501
8d13d08b9232 (svn r3027) -Feature: [OSX] command+q now works in main menu (Tobin)
bjarni
parents: 2469
diff changeset
  2205
		}
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1397
diff changeset
  2206
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2207
		/* 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
  2208
		 * 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
  2209
		 * 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
  2210
		 * 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
  2211
		if (IsGeneratingWorld()) break;
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2212
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  2213
		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
  2214
			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
  2215
			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
  2216
			break;
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2217
		}
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2218
7643
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2219
		if (e->we.keypress.keycode == ('B' | WKC_CTRL)) {
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2220
			e->we.keypress.cont = false;
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2221
			_draw_bounding_boxes = !_draw_bounding_boxes;
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2222
			MarkWholeScreenDirty();
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2223
			break;
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2224
		}
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
  2225
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  2226
		if (_game_mode == GM_MENU) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2227
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  2228
		switch (e->we.keypress.keycode) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2229
			case 'C':
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2230
			case 'Z': {
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2231
				Point pt = GetTileBelowCursor();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2232
				if (pt.x != -1) {
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2233
					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
  2234
					if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2235
				}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2236
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2237
			}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2238
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2239
			case WKC_ESC: ResetObjectToPlace(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2240
			case WKC_DELETE: DeleteNonVitalWindows(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2241
			case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2242
			case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2243
1772
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
  2244
#if defined(_DEBUG)
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2245
			case '0' | WKC_ALT: // Crash the game
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2246
				*(byte*)0 = 0;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2247
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2248
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2249
			case '1' | WKC_ALT: // Gimme money
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2250
				/* Server can not cheat in advertise mode either! */
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2251
				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
  2252
					DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2253
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2254
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2255
			case '2' | WKC_ALT: // Update the coordinates of all station signs
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2256
				UpdateAllStationVirtCoord();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2257
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2258
#endif
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2259
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2260
			case '1' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2261
			case '2' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2262
			case '3' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2263
			case '4' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2264
			case '5' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2265
			case '6' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2266
			case '7' | WKC_CTRL:
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  2267
			case '8' | WKC_CTRL:
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2268
				/* Transparency toggle hot keys */
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  2269
				ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2270
				MarkWholeScreenDirty();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2271
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2272
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2273
			case 'X' | WKC_CTRL:
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2274
				ShowTransparencyToolbar();
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2275
				break;
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2276
6494
b41e51f3c9ef (svn r9677) -Codechange: Make the 'transparent buildings' menu item toggle all transparency, to keep its old behaviour.
peter1138
parents: 6492
diff changeset
  2277
			case 'X':
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  2278
				ResetRestoreAllTransparency();
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2279
				break;
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
  2280
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  2281
#ifdef ENABLE_NETWORK
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2282
			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
  2283
				if (_networking) {
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2284
					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
  2285
					bool teamchat = false;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2286
5672
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2287
					if (cio == NULL) break;
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2288
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2289
					/* 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
  2290
					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
  2291
						const NetworkClientInfo *ci;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2292
						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
  2293
							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
  2294
								teamchat = true;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2295
								break;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2296
							}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2297
						}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2298
					}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2299
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  2300
					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
  2301
				}
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2302
				break;
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2303
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2304
			case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2305
				if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2306
				break;
4887
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2307
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2308
			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
  2309
				if (_networking) {
5672
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2310
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2311
					if (cio == NULL) break;
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2312
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
  2313
					ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
4887
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2314
				}
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  2315
				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
  2316
#endif
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
  2317
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2318
			default: return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2319
		}
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  2320
		e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2321
		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
  2322
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
  2323
		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
  2324
			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
  2325
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
  2326
			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
  2327
				_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
  2328
				_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
  2329
			}
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
  2330
6654
31d17823506f (svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents: 6626
diff changeset
  2331
			WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
31d17823506f (svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents: 6626
diff changeset
  2332
			WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
6730
9311a208f8f7 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 6691
diff changeset
  2333
			WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
9311a208f8f7 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 6691
diff changeset
  2334
			WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
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
  2335
		} 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
  2336
e705eef174bf (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
  2337
		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
  2338
			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
  2339
			break;
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  2340
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  2341
		case WE_MESSAGE:
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  2342
			/* 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
  2343
			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
  2344
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2345
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2346
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2347
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2348
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2349
void ShowSelectGameWindow();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2350
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2351
void SetupColorsAndInitialWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2352
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2353
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2354
	Window *w;
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
  2355
	int width, height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2356
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2357
	for (i = 0; i != 16; i++) {
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  2358
		const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i);
1357
0a4c07b68673 (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1350
diff changeset
  2359
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2360
		assert(b);
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4434
diff changeset
  2361
		memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2362
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2363
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2364
	width = _screen.width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2365
	height = _screen.height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2366
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2367
	w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents: 6591
diff changeset
  2368
	AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2369
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
  2370
	/* XXX: these are not done */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2371
	switch (_game_mode) {
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2372
		default: NOT_REACHED();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2373
		case GM_MENU:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2374
			ShowSelectGameWindow();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2375
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2376
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2377
		case GM_NORMAL:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2378
		case GM_EDITOR:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2379
			ShowVitalWindows();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2380
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2381
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2382
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2383
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2384
void ShowVitalWindows()
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
  2385
{
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
  2386
	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
  2387
5048
b784951def0a (svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents: 5046
diff changeset
  2388
	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
  2389
	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
  2390
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
  2391
	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
  2392
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  2393
	w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  2394
	w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1015
diff changeset
  2395
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2396
	/* '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
  2397
	PositionMainToolbar(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2398
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2399
	/* Status bad only for normal games */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2400
	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
  2401
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
  2402
	_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
  2403
	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
  2404
	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
  2405
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
  2406
	WP(w, def_d).data_1 = -1280;
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
  2407
}
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
  2408
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2409
void GameSizeChanged()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2410
{
2429
5e5b66fb8420 (svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents: 2361
diff changeset
  2411
	_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
  2412
	_cur_resolution[1] = _screen.height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2413
	RelocateAllWindows(_screen.width, _screen.height);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2414
	ScreenSizeChanged();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2415
	MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2416
}
3622
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2417
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2418
void InitializeMainGui()
3622
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2419
{
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2420
	/* 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
  2421
	_last_built_railtype = RAILTYPE_RAIL;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
  2422
	_last_built_roadtype = ROADTYPE_ROAD;
3622
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2423
}
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5108
diff changeset
  2424
5237
4fce3ea379c2 (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 5235
diff changeset
  2425
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  2426
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7657
diff changeset
  2427
8056
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  2428