src/main_gui.cpp
author maedhros
Sun, 27 Jan 2008 17:32:12 +0000
changeset 8424 c3477565c975
parent 8270 e7c342f6b14c
child 8448 f716c812f401
permissions -rw-r--r--
(svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
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"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#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
    11
#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
    12
#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
    13
#include "textbuf_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    14
#include "viewport_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    15
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "news.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "town.h"
126
152df0cc4ac2 (svn r127) New feature: ingame console. (sign_de)
dominik
parents: 116
diff changeset
    18
#include "console.h"
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents: 983
diff changeset
    19
#include "signs.h"
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1500
diff changeset
    20
#include "waypoint.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    21
#include "variables.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2652
diff changeset
    22
#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
    23
#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
    24
#include "bridge_map.h"
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
    25
#include "screenshot.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    26
#include "genworld.h"
4668
f7256d0e7682 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    27
#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
    28
#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
    29
#include "newgrf_config.h"
8111
02d19f43eea6 (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8108
diff changeset
    30
#include "rail_gui.h"
02d19f43eea6 (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8108
diff changeset
    31
#include "road_gui.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    32
#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
    33
#include "functions.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    34
#include "vehicle_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8149
diff changeset
    35
#include "sound_func.h"
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8144
diff changeset
    36
#include "fios.h"
8205
2bde724f1b5d (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8196
diff changeset
    37
#include "terraform_gui.h"
4942
7fb6c39eb421 (svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents: 4938
diff changeset
    38
#include "industry.h"
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
    39
#include "transparency.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8111
diff changeset
    40
#include "strings_func.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    41
#include "zoom_func.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8208
diff changeset
    42
#include "string_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    43
#include "player_base.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    44
#include "player_func.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    45
#include "player_gui.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    46
#include "settings_type.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    48
#include "network/network.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    49
#include "network/network_data.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    50
#include "network/network_client.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    51
#include "network/network_server.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    52
#include "network/network_gui.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    53
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    54
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    55
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    56
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    57
static int _rename_id = 1;
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    58
static int _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5108
diff changeset
    60
RailType _last_built_railtype;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
    61
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
    62
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
    63
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    64
extern void GenerateIndustries();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    65
extern bool GenerateTowns();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
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
    67
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
    68
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    69
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
    70
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
    71
{
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    72
#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
    73
	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
    74
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
	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
    76
	/* 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
    77
	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
    78
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
	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
    80
		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
    81
	} 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
    82
		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
    83
	}
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    84
#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
    85
}
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
    86
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    87
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
    88
{
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    89
	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
    90
	_cmd_text = str;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    91
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
    92
	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
    93
	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
    94
		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
    95
		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
    96
		break;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    97
#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
    98
	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
    99
		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
   100
		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
   101
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
   102
		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
   103
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
   104
		/* 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
   105
		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
   106
	} break;
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   107
#endif /* ENABLE_NETWORK */
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   108
		default: NOT_REACHED();
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   109
	}
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   110
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
   111
	_rename_id = _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
1070
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   114
/**
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   115
 * This code is shared for the majority of the pushbuttons.
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   116
 * 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
   117
 *
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   118
 * @param w Window which called the function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   119
 * @param widget ID of the widget (=button) that called this function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
   120
 * @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
   121
 * @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
   122
 * @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
   123
 * @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
   124
 */
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
   125
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
   126
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   127
	if (w->IsWidgetDisabled(widget)) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
2621
2bacc2e9c68f (svn r3159) Remove the read-only variable _no_button_sound
tron
parents: 2615
diff changeset
   129
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
	SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   132
	if (w->IsWidgetLowered(widget)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
   137
	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
   138
	w->LowerWidget(widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
	_place_proc = placeproc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   144
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
   145
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   146
	if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
static void ToolbarPauseClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
{
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   152
	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
   153
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
   154
	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
   155
}
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
static void ToolbarFastForwardClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	_fast_forward ^= true;
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   160
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   164
static void MenuClickSettings(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   166
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   167
		case 0: ShowGameOptions();      return;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   168
		case 1: ShowGameDifficulty();   return;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   169
		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
   170
		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
   171
		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
   172
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
   173
		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
   174
		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
   175
		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
   176
		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
   177
		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
   178
		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
   179
		case 12:
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   180
			ToggleTransparency(TO_TREES);
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   181
			ToggleTransparency(TO_HOUSES);
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   182
			break;
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
   183
		case 13: ToggleTransparency(TO_SIGNS);                   break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	}
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   185
	MarkWholeScreenDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   188
static void MenuClickSaveLoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	if (_game_mode == GM_EDITOR) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   191
		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
   192
			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
   193
			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
   194
			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
   195
			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
   196
			case 5: HandleExitGameRequest();                break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	} else {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   199
		switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   200
			case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   201
			case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   202
			case 2: AskExitToGameMenu();               break;
4548
6165e12570bf (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
   203
			case 3: HandleExitGameRequest();           break;
0
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   208
static void MenuClickMap(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   210
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   211
		case 0: ShowSmallMap();            break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   212
		case 1: ShowExtraViewPortWindow(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   213
		case 2: ShowSignList();            break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   217
static void MenuClickTown(int index)
0
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
	ShowTownDirectory();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   222
static void MenuClickScenMap(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   224
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   225
		case 0: ShowSmallMap();            break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   226
		case 1: ShowExtraViewPortWindow(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   227
		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
   228
		case 3: ShowTownDirectory();       break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   232
static void MenuClickSubsidies(int index)
0
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
	ShowSubsidiesList();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   237
static void MenuClickStations(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   239
	ShowPlayerStations((PlayerID)index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   242
static void MenuClickFinances(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   244
	ShowPlayerFinances((PlayerID)index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   247
static void MenuClickCompany(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
{
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   249
	if (_networking && index == 0) {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   250
		ShowClientList();
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   251
	} else {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   252
		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
   253
		ShowPlayerCompany((PlayerID)index);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   254
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   256
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   257
static void MenuClickGraphs(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   259
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   260
		case 0: ShowOperatingProfitGraph();    break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   261
		case 1: ShowIncomeGraph();             break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   262
		case 2: ShowDeliveredCargoGraph();     break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   263
		case 3: ShowPerformanceHistoryGraph(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   264
		case 4: ShowCompanyValueGraph();       break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   265
		case 5: ShowCargoPaymentRates();       break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   269
static void MenuClickLeague(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   271
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   272
		case 0: ShowCompanyLeagueTable();      break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   273
		case 1: ShowPerformanceRatingDetail(); break;
116
ca4332a9ec1d (svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents: 74
diff changeset
   274
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   277
static void MenuClickIndustry(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   279
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   280
		case 0: ShowIndustryDirectory();   break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   281
		case 1: ShowBuildIndustryWindow(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   285
static void MenuClickShowTrains(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
{
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
   287
	ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   290
static void MenuClickShowRoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
{
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
   292
	ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   295
static void MenuClickShowShips(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
{
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
   297
	ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   300
static void MenuClickShowAir(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
{
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
   302
	ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   305
static void MenuClickBuildRail(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   307
	_last_built_railtype = (RailType)index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	ShowBuildRailToolbar(_last_built_railtype, -1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   311
static void MenuClickBuildRoad(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
{
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   313
	_last_built_roadtype = (RoadType)index;
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
   314
	ShowBuildRoadToolbar(_last_built_roadtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   317
static void MenuClickBuildWater(int index)
0
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
	ShowBuildDocksToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   322
static void MenuClickBuildAir(int index)
0
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
	ShowBuildAirToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   327
#ifdef ENABLE_NETWORK
4830
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4824
diff changeset
   328
void ShowNetworkGiveMoneyWindow(PlayerID player)
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   329
{
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   330
	_rename_id = player;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   331
	_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
   332
	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
   333
}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   334
#endif /* ENABLE_NETWORK */
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   335
2116
23031555ff54 (svn r2626) static, const, misc.
tron
parents: 2092
diff changeset
   336
void ShowRenameWaypointWindow(const Waypoint *wp)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
{
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1500
diff changeset
   338
	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
   339
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   340
	/* 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
   341
	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
   342
		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
   343
			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
   344
		return;
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   345
	}
eaada71b7c85 (svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents: 682
diff changeset
   346
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
	_rename_id = id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
	_rename_what = 1;
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   349
	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
   350
	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
   351
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   353
static void SelectSignTool()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   355
	if (_cursor.sprite == SPR_CURSOR_SIGN) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
		ResetObjectToPlace();
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   357
	} else {
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
   358
		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
   359
		_place_proc = PlaceProc_Sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   363
static void MenuClickForest(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   365
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   366
		case 0: ShowTerraformToolbar();  break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   367
		case 1: ShowBuildTreesToolbar(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   368
		case 2: SelectSignTool();        break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   372
static void MenuClickMusicWindow(int index)
0
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
	ShowMusicWindow();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   377
static void MenuClickNewspaper(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
{
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   379
	switch (index) {
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   380
		case 0: ShowLastNewsMessage(); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   381
		case 1: ShowMessageOptions();  break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2630
diff changeset
   382
		case 2: ShowMessageHistory();  break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   386
static void MenuClickSmallScreenshot()
4184
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
	SetScreenshotType(SC_VIEWPORT);
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   389
}
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   390
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   391
static void MenuClickWorldScreenshot()
4184
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
	SetScreenshotType(SC_WORLD);
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   394
}
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   395
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
   396
static void MenuClickHelp(int index)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
{
2432
c48585a8b05f (svn r2958) - Feature: [ 1258971 ] Menu option to toggle console. Mainly for MacOS's or PDA's. (toholio)
Darkvater
parents: 2430
diff changeset
   398
	switch (index) {
4184
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   399
		case 0: PlaceLandBlockInfo();       break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   400
		case 2: IConsoleSwitch();           break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   401
		case 3: MenuClickSmallScreenshot(); break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   402
		case 4: MenuClickWorldScreenshot(); break;
541f819f2125 (svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents: 4171
diff changeset
   403
		case 5: ShowAboutWindow();          break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   407
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   408
typedef void MenuClickedProc(int index);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   409
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
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
   411
	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
   412
	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
   413
	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
   414
	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
   415
	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
   416
	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
   417
	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
   418
	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
   419
	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
   420
	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
   421
	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
   422
	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
   423
	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
   424
	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
   425
	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
   426
	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
   427
	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
   428
	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
   429
	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
   430
	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
   431
	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
   432
	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
   433
	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
   434
	MenuClickForest,      /* 23 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
	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
   436
	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
   437
	MenuClickHelp,        /* 26 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
static void MenuWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   442
	switch (e->event) {
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   443
		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
   444
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
	case WE_PAINT: {
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   446
		int x, y;
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   447
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   448
		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
   449
		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
   450
		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
   451
		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
   452
		byte dis = WP(w, menu_d).disabled_items;
0
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
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
		x = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
		y = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   459
		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
   460
			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
   461
			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
   462
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
   463
			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
   464
			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
   465
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
			chk >>= 1;
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   468
			dis >>= 1;
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   469
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
	case WE_DESTROY: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
			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
   474
			v->RaiseWidget(WP(w, menu_d).main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
			SetWindowDirty(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   478
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
	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
   480
		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
   481
		int action_id;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   482
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
		if (index < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
			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
   486
			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
   487
				index = WP(w, menu_d).sel_index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   490
		action_id = WP(w, menu_d).action_id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
		DeleteWindow(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   492
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   493
		if (index >= 0) {
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   494
			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
   495
			_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
   496
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   497
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
		}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   500
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
	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
   502
		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
   503
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   504
		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
   505
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   506
		WP(w, menu_d).sel_index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
		return;
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   513
/* 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
   514
 * 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
   515
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
   516
{    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
   517
{ WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 815
diff changeset
   521
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
   522
{    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
   523
{ WIDGETS_END},
0
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
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
static int GetPlayerIndexFromMenu(int index)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
	if (index >= 0) {
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   530
		const Player *p;
2630
7206058a7e82 (svn r3172) static, const
tron
parents: 2621
diff changeset
   531
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
		FOR_ALL_PLAYERS(p) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   533
			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
   534
		}
0
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
	return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
static void UpdatePlayerMenuHeight(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
{
4824
c49e6ffcb89a (svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents: 4822
diff changeset
   541
	byte num = ActivePlayerCount();
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   542
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
   543
	/* 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
   544
	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
   545
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   546
	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
   547
		WP(w, menu_d).item_count = num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
		num = num * 10 + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
		w->height = num;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 815
diff changeset
   551
		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
   552
		SetWindowDirty(w);
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
static void PlayerMenuWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   558
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
		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
   561
		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
   562
		TextColour color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
		Player *p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
		uint16 chk;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
		UpdatePlayerMenuHeight(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
		x = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
		y = 1;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   571
		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
   572
		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
   573
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
   574
		/* 9 = playerlist */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   575
		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
   576
			if (sel == 0) {
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   577
				GfxFillRect(x, y, x + 238, y + 9, 0);
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   578
			}
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
   579
			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
   580
			y += 10;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   581
			sel--;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   582
		}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   583
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
		FOR_ALL_PLAYERS(p) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
			if (p->is_active) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
				if (p->index == sel) {
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   587
					GfxFillRect(x, y, x + 238, y + 9, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
				}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   589
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   590
				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
   591
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
   592
				SetDParam(0, p->index);
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
   593
				SetDParam(1, p->index);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   594
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
   595
				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
   596
				if (chk&1) color = TC_GREY;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   597
				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
   598
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
				y += 10;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   600
			}
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   601
			chk >>= 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   603
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
	case WE_DESTROY: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
		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
   609
		v->RaiseWidget(WP(w, menu_d).main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
		SetWindowDirty(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   613
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
	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
   615
		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
   616
		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
   617
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
   618
		/* 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
   619
		 *  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
   620
		if (_networking && WP(w, menu_d).main_button == 9) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   621
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   622
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   623
			index = GetPlayerIndexFromMenu(index);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   624
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   625
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
		if (index < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
			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
   628
			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
   629
				index = WP(w, menu_d).sel_index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
		DeleteWindow(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   633
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
		if (index >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
			assert(index >= 0 && index < 30);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
			_menu_clicked_procs[action_id](index);
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
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
	case WE_POPUPMENU_OVER: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
		int index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
		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
   643
		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
   644
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
   645
		/* 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
   646
		 * 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
   647
		if (_networking && WP(w, menu_d).main_button == 9) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   648
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   649
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   650
			index = GetPlayerIndexFromMenu(index);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   651
		}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   652
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   653
		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
   654
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   655
		WP(w, menu_d).sel_index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
		return;
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   662
/** 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
   663
 * 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
   664
 * @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
   665
 * @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
   666
 * @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
   667
static int GetStringListMaxWidth(StringID base_string, byte count)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
{
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   669
	char buffer[512];
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   670
	int width, max_width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   671
	byte i;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   672
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   673
	max_width = 0;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   674
	for (i = 0; i != count; i++) {
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4907
diff changeset
   675
		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
   676
		width = GetStringBoundingBox(buffer).width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   677
		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
   678
	}
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
	return max_width;
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   681
}
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   682
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   683
/** 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
   684
 * 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
   685
 * 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
   686
 * 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
   687
 * 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
   688
 * 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
   689
 * 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
   690
 * @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
   691
 * 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
   692
 * @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
   693
 * 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
   694
 * 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
   695
 * 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
   696
 * 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
   697
 * as button. So<br>
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   698
 * 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
   699
 * 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
   700
 * @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
   701
 * 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
   702
 * @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
   703
 * @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
   704
 * @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
   705
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
   706
{
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   707
	int width;
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   708
	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
   709
4820
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   710
	assert(disabled_mask == 0 || item_count <= 8);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   711
	w->LowerWidget(parent_button);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
   712
	w->InvalidateWidget(parent_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   716
	/* 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
   717
	 * 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
   718
	 * 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
   719
	 * 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
   720
	 * 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
   721
	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
   722
	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
   723
dd69fb4c3fcd (svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents: 4781
diff changeset
   724
	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
   725
	w->widget[0].bottom = item_count * 10 + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   727
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   728
	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
   729
	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
   730
	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
   731
	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
   732
	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
   733
	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
   734
	WP(w, menu_d).disabled_items = disabled_mask;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
	_popup_menu_active = true;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   737
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   738
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
	return w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
}
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
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
   743
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   744
	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
   745
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   746
	w->LowerWidget(main_button);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
   747
	w->InvalidateWidget(main_button);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
	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
   751
	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
   752
	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
   753
	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
   754
	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
   755
		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
   756
			WP(w, menu_d).sel_index++;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   757
		} else {
724
a73dec475b53 (svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents: 722
diff changeset
   758
			/* 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
   759
			WP(w, menu_d).sel_index = 0;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   760
		}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   761
	}
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   762
	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
   763
	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
   764
	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
   765
	WP(w, menu_d).disabled_items = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
	_popup_menu_active = true;
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   767
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
	return w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
static void ToolbarSaveClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   773
	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
   774
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
static void ToolbarMapClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
{
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
   778
	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
   779
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   780
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   781
static void ToolbarTownClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   782
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   783
	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
   784
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
static void ToolbarSubsidiesClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   788
	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
static void ToolbarStationsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   793
	PopupMainPlayerToolbMenu(w, 7, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
static void ToolbarMoneyClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   797
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   798
	PopupMainPlayerToolbMenu(w, 8, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   800
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   801
static void ToolbarPlayersClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
{
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   803
	PopupMainPlayerToolbMenu(w, 9, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   806
static void ToolbarGraphsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   808
	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
   809
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   811
static void ToolbarLeagueClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   813
	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
   814
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
static void ToolbarIndustryClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   818
	/* 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
   819
	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
   820
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
static void ToolbarTrainClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   824
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   825
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   826
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   827
	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
   828
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   829
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   830
	PopupMainPlayerToolbMenu(w, 13, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   833
static void ToolbarRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   835
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   837
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   838
	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
   839
		if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   840
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   841
	PopupMainPlayerToolbMenu(w, 14, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
static void ToolbarShipClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   846
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   848
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   849
	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
   850
		if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   851
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   852
	PopupMainPlayerToolbMenu(w, 15, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
static void ToolbarAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   857
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
	int dis = -1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   859
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   860
	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
   861
		if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   862
	}
7357
de2fe2f2462c (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7341
diff changeset
   863
	PopupMainPlayerToolbMenu(w, 16, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   864
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
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
   866
/* 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
   867
/* 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
   868
bool DoZoomInOutWindow(int how, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   869
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   870
	ViewPort *vp;
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   871
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   872
	assert(w != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   873
	vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   875
	switch (how) {
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   876
		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
   877
			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
   878
			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
   879
			vp->virtual_width >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   880
			vp->virtual_height >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   881
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   882
			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
   883
			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
   884
			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
   885
			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
   886
			break;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   887
		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
   888
			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
   889
			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
   890
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
   891
			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
   892
			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
   893
			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
   894
			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
   895
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   896
			vp->virtual_width <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   897
			vp->virtual_height <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   898
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   899
	}
5214
62a0325b53c7 (svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents: 5118
diff changeset
   900
	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
   901
		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
   902
		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
   903
	}
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   904
	SetWindowDirty(w);
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   905
	/* 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
   906
	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
   907
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
static void ToolbarZoomInClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
{
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
   912
	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
   913
		w->HandleButtonClick(17);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   914
		SndPlayFx(SND_15_BEEP);
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   918
static void ToolbarZoomOutClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   919
{
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
   920
	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
   921
		w->HandleButtonClick(18);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   922
		SndPlayFx(SND_15_BEEP);
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   926
static void ToolbarBuildRailClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   927
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   928
	const Player *p = GetPlayer(_local_player);
6685
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   929
	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
   930
	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
   931
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
static void ToolbarBuildRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
{
6685
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   935
	const Player *p = GetPlayer(_local_player);
00490513d7b1 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 6672
diff changeset
   936
	/* 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
   937
	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
   938
	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
   939
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   941
static void ToolbarBuildWaterClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   943
	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
   944
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
static void ToolbarBuildAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   948
	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
   949
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   950
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   951
static void ToolbarForestClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   953
	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   955
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
static void ToolbarMusicClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   958
	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
   959
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   960
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   961
static void ToolbarNewspaperClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   962
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   963
	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
   964
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   965
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   966
static void ToolbarHelpClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   967
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   968
	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
   969
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
static void ToolbarOptionsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   972
{
4822
cc1a5189d4d7 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   973
	uint16 x = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   974
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8270
diff changeset
   975
	w = PopupMainToolbMenu(w, 2, STR_02C4_GAME_OPTIONS, 14, 0);
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
   976
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
   977
	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
   978
	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
   979
	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
   980
	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
   981
	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
   982
	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
   983
	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
   984
	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
   985
	WP(w, menu_d).checked_items = x;
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   988
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   989
static void ToolbarScenSaveOrLoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
{
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
   991
	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
   992
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   994
static void ToolbarScenDateBackward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   995
{
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
   996
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   997
	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
   998
		w->HandleButtonClick(6);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   999
		SetWindowDirty(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1000
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
  1001
		_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
  1002
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
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
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1007
static void ToolbarScenDateForward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
{
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
  1009
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1010
	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
  1011
		w->HandleButtonClick(7);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1012
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
  1014
		_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
  1015
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
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
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
static void ToolbarScenMapTownDir(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1021
{
4821
71d1da6c6f03 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
  1022
	/* 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
  1023
	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
  1024
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1025
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1026
static void ToolbarScenZoomIn(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1027
{
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
  1028
	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
  1029
		w->HandleButtonClick(9);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1030
		SndPlayFx(SND_15_BEEP);
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
static void ToolbarScenZoomOut(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
{
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
  1036
	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
  1037
		w->HandleButtonClick(10);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1038
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1039
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1040
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1042
void ZoomInOrOutToCursorWindow(bool in, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1043
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1044
	ViewPort *vp;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1045
	Point pt;
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
	assert(w != 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1048
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1049
	vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1050
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1051
	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
  1052
		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
  1053
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
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
  1055
		pt = GetTileZoomCenterWindow(in,w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
		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
  1057
			ScrollWindowTo(pt.x, pt.y, w, true);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
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
  1059
			DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
0
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1062
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1063
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1064
static void ToolbarScenGenLand(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1065
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1066
	w->HandleButtonClick(11);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1067
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1068
8205
2bde724f1b5d (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8196
diff changeset
  1069
	ShowEditorTerraformToolbar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1070
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1071
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1072
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
  1073
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1074
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1075
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1076
		ResetObjectToPlace();
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1079
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
  1080
static void PlaceProc_Town(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
{
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1082
	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
  1083
	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
  1084
	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
  1085
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1086
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1088
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
  1089
{   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
  1090
{    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
  1091
{  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
  1092
{      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
  1093
{    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
  1094
{    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
  1095
{    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
  1096
{    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
  1097
{    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
  1098
{    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
  1099
{    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
  1100
{      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
  1101
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1104
static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1105
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1106
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1108
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1109
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
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
  1111
	case WE_CREATE:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1112
		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
  1113
		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
  1114
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
	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
  1116
		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
  1117
		case 4: // new town
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
  1118
			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
  1119
			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
  1120
		case 5: {// random town
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1121
			Town *t;
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1122
			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
  1123
			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
  1124
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1125
			w->HandleButtonClick(5);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1126
			_generating_world = true;
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1127
			t = CreateRandomTown(20, mode, size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1128
			_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
  1129
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
  1130
			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
  1131
				ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1132
			} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
				ScrollMainWindowToTile(t->xy);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1134
			}
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
  1135
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1136
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
		}
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
  1138
		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
  1139
			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
  1140
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1141
			_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
  1142
			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
  1143
			_generating_world = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1144
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1145
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1146
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6481
diff changeset
  1147
		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
  1148
			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
  1149
			_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
  1150
			w->LowerWidget(_scengen_town_size + 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1151
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1152
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1153
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1155
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1156
	case WE_TIMEOUT:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1157
		w->RaiseWidget(5);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1158
		w->RaiseWidget(6);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1159
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1160
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1161
	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
  1162
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1163
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
	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
  1165
		w->RaiseButtons();
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1166
		w->LowerWidget(_scengen_town_size + 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1168
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1172
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
  1173
	WDP_AUTO, WDP_AUTO, 160, 95, 160, 95,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1174
	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
  1175
	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
  1176
	_scen_edit_town_gen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
	ScenEditTownGenWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1178
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1179
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1180
static void ToolbarScenGenTown(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1181
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1182
	w->HandleButtonClick(12);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1183
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1185
	AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1186
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1187
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1188
static void ToolbarScenGenIndustry(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1190
	w->HandleButtonClick(13);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1191
	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
  1192
	ShowBuildIndustryWindow();
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1195
static void ToolbarScenBuildRoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1196
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1197
	w->HandleButtonClick(14);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1198
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1199
	ShowBuildRoadScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1200
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1201
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1202
static void ToolbarScenPlantTrees(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1203
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1204
	w->HandleButtonClick(15);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1205
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1206
	ShowBuildTreesScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1207
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1209
static void ToolbarScenPlaceSign(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1210
{
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8032
diff changeset
  1211
	w->HandleButtonClick(16);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
  1212
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1213
	SelectSignTool();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1214
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1215
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1216
static void ToolbarBtn_NULL(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1217
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1218
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1219
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1220
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1221
typedef void ToolbarButtonProc(Window *w);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1222
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1223
static ToolbarButtonProc * const _toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1224
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1225
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1226
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1227
	ToolbarSaveClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1228
	ToolbarMapClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1229
	ToolbarTownClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1230
	ToolbarSubsidiesClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1231
	ToolbarStationsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1232
	ToolbarMoneyClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1233
	ToolbarPlayersClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1234
	ToolbarGraphsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1235
	ToolbarLeagueClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1236
	ToolbarIndustryClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1237
	ToolbarTrainClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1238
	ToolbarRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1239
	ToolbarShipClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1240
	ToolbarAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1241
	ToolbarZoomInClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1242
	ToolbarZoomOutClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1243
	ToolbarBuildRailClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1244
	ToolbarBuildRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1245
	ToolbarBuildWaterClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1246
	ToolbarBuildAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1247
	ToolbarForestClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1248
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1249
	ToolbarNewspaperClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1250
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1252
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1253
static void MainToolbarWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1254
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  1255
	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
  1256
	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
  1257
		/* Draw brown-red toolbar bg. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1258
		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
  1259
		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
  1260
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1261
		/* If spectator, disable all construction buttons
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1262
		 * ie : Build road, rail, ships, airports and landscaping
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
  1263
		 * 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
  1264
		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
  1265
		/* 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
  1266
		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
  1267
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1268
		w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1269
		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
  1270
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1271
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1272
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1274
	case WE_CLICK: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1275
		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
  1276
			_toolbar_button_procs[e->we.click.widget](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1277
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1279
	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
  1280
		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
  1281
		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
  1282
		case WKC_F2: ShowGameOptions(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1283
		case WKC_F3: MenuClickSaveLoad(0); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1284
		case WKC_F4: ShowSmallMap(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1285
		case WKC_F5: ShowTownDirectory(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1286
		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
  1287
		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
  1288
		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
  1289
		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
  1290
		case WKC_F10: ShowOperatingProfitGraph(); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1291
		case WKC_F11: ShowCompanyLeagueTable(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1292
		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
  1293
		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
  1294
		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
  1295
		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
  1296
		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
  1297
		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
  1298
		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
  1299
		case WKC_SHIFT | WKC_EQUALS: // Fall through
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1300
		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
  1301
		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
  1302
		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
  1303
		case WKC_SHIFT | WKC_MINUS: // Fall through
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1304
		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
  1305
		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
  1306
		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
  1307
		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
  1308
		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
  1309
		case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1310
		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
  1311
		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
  1312
		case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1313
		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
  1314
		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
  1315
		case 'L': ShowTerraformToolbar(); break;
7310
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7266
diff changeset
  1316
		case 'M': ShowSmallMap(); break;
eed5036fee1f (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7266
diff changeset
  1317
		case 'V': ShowExtraViewPortWindow(); break;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1397
diff changeset
  1318
		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
  1319
		}
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  1320
		e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1321
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1322
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1323
	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
  1324
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1325
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1326
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1327
	case WE_ABORT_PLACE_OBJ: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1328
		w->RaiseWidget(25);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1329
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1330
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1331
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1332
	case WE_MOUSELOOP:
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1333
		if (w->IsWidgetLowered(0) != !!_pause_game) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1334
			w->ToggleWidgetLoweredState(0);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1335
			w->InvalidateWidget(0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1336
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1337
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1338
		if (w->IsWidgetLowered(1) != !!_fast_forward) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1339
			w->ToggleWidgetLoweredState(1);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1340
			w->InvalidateWidget(1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1341
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1342
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1343
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
  1344
	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
  1345
		/* 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
  1346
		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
  1347
		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
  1348
		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
  1349
			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
  1350
			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
  1351
		} 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
  1352
			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
  1353
			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
  1354
		}
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
  1355
		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
  1356
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
  1357
		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
  1358
			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
  1359
				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
  1360
				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
  1361
				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
  1362
				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
  1363
			}
7361
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1364
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1365
			w->widget[i].left = x;
a9616513ea49 (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7360
diff changeset
  1366
			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
  1367
			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
  1368
		}
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
  1369
	} 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
  1370
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1371
	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
  1372
		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
  1373
		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
  1374
			if (w->IsWidgetLowered(i)) {
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1375
				w->RaiseWidget(i);
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1376
				w->InvalidateWidget(i);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1377
			}
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1378
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1379
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1380
	}
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1381
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1382
		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
  1383
			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
  1384
			break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1385
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1386
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1388
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
  1389
{     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
  1390
{     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
  1391
{     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
  1392
{   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
  1393
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
  1394
{     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
  1395
{     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
  1396
{     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
  1397
{     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
  1398
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
  1399
{     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
  1400
{     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
  1401
{     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
  1402
{     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
  1403
{     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
  1404
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
  1405
{     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
  1406
{     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
  1407
{     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
  1408
{     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
  1409
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
  1410
{     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
  1411
{     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
  1412
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
  1413
{     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
  1414
{     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
  1415
{     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
  1416
{     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
  1417
{     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
  1418
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
  1419
{     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
  1420
{     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
  1421
{     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
  1422
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1423
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1425
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
  1426
	0, 0, 0, 22, 640, 22,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1427
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1428
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1429
	_toolb_normal_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1430
	MainToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1431
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1432
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
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
  1435
{  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
  1436
{  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
  1437
{  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
  1438
{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
  1439
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
  1440
{   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
  1441
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
  1442
{   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
  1443
{  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
  1444
{  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
  1445
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
  1446
{  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
  1447
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
  1448
{  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
  1449
{  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
  1450
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
  1451
{  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
  1452
{  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
  1453
{  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
  1454
{  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
  1455
{  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
  1456
{  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
  1457
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1458
{   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
  1459
{   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
  1460
{   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
  1461
{   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
  1462
{   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
  1463
{   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
  1464
{   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
  1465
{  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
  1466
{   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
  1467
{  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
  1468
{WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1469
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1470
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1471
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1472
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1473
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1474
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1475
	ToolbarScenSaveOrLoad,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1476
	ToolbarBtn_NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1477
	ToolbarBtn_NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1478
	ToolbarScenDateBackward,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1479
	ToolbarScenDateForward,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1480
	ToolbarScenMapTownDir,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1481
	ToolbarScenZoomIn,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1482
	ToolbarScenZoomOut,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1483
	ToolbarScenGenLand,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1484
	ToolbarScenGenTown,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1485
	ToolbarScenGenIndustry,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1486
	ToolbarScenBuildRoad,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1487
	ToolbarScenPlantTrees,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1488
	ToolbarScenPlaceSign,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1489
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1490
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1491
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1492
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1493
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1494
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1495
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1496
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1497
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1498
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1499
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1500
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1501
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1502
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  1503
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1504
	case WE_PAINT:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1505
		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
  1506
		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
  1507
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
  1508
		/* Draw brown-red toolbar bg. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1509
		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
  1510
		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
  1511
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1512
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1513
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  1514
		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
  1515
		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
  1516
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
  1517
		/* 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
  1518
		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
  1519
			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
  1520
			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
  1521
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1522
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1523
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1524
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1525
	case WE_CLICK: {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1526
		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
  1527
		_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
  1528
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1529
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1530
	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
  1531
		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
  1532
			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
  1533
			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
  1534
			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
  1535
			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
  1536
			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
  1537
			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
  1538
			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
  1539
			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
  1540
			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
  1541
			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
  1542
			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
  1543
			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
  1544
			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
  1545
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1546
			/* 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
  1547
			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
  1548
			case WKC_EQUALS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1549
			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
  1550
			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
  1551
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1552
			/* 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
  1553
			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
  1554
			case WKC_MINUS:
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  1555
			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
  1556
			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
  1557
8205
2bde724f1b5d (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8196
diff changeset
  1558
			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
  1559
			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
  1560
			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
  1561
			default: return;
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1562
		}
5006
390d6334da67 (svn r7023) -Fix: Pressing F1 in scenario editor did not work because the keypress event was sent
Darkvater
parents: 5005
diff changeset
  1563
		e->we.keypress.cont = false;
2755
ba133949851b (svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents: 2753
diff changeset
  1564
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1565
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1566
	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
  1567
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1568
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1569
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1570
	case WE_ABORT_PLACE_OBJ: {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1571
		w->RaiseWidget(25);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1572
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
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
  1575
	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
  1576
		/* 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
  1577
		 * 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
  1578
		 * 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
  1579
		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
  1580
		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
  1581
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
  1582
		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
  1583
		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
  1584
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
  1585
		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
  1586
			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
  1587
			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
  1588
		} 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
  1589
			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
  1590
			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
  1591
		}
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
  1592
		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
  1593
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
  1594
		/* 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
  1595
		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
  1596
			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
  1597
				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
  1598
					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
  1599
					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
  1600
						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
  1601
						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
  1602
						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
  1603
					}
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
  1604
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
  1605
					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
  1606
					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
  1607
					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
  1608
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
  1609
				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
  1610
					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
  1611
					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
  1612
					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
  1613
					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
  1614
					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
  1615
					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
  1616
					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
  1617
					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
  1618
					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
  1619
				} 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
  1620
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
  1621
				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
  1622
					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
  1623
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
  1624
					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
  1625
					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
  1626
					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
  1627
					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
  1628
					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
  1629
					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
  1630
			}
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
  1631
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
  1632
			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
  1633
				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
  1634
				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
  1635
				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
  1636
				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
  1637
			}
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
  1638
		}
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
  1639
	} 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
  1640
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1641
	case WE_MOUSELOOP:
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1642
		if (w->IsWidgetLowered(0) != !!_pause_game) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1643
			w->ToggleWidgetLoweredState(0);
24
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1644
			SetWindowDirty(w);
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1645
		}
5c611497f25a (svn r25) Fix: [ 1007630 ] Scenario editor pause bug
dominik
parents: 7
diff changeset
  1646
8070
8e068f2e265a (svn r11631) -Fix (r11585, r11626): remove MSVC warnings
glx
parents: 8065
diff changeset
  1647
		if (w->IsWidgetLowered(1) != !!_fast_forward) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  1648
			w->ToggleWidgetLoweredState(1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1649
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1650
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1651
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1652
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1653
		case WE_MESSAGE:
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1654
			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
  1655
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1656
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1657
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1658
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1659
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
  1660
	0, 0, 130, 22, 640, 22,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1661
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1662
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1663
	_toolb_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1664
	ScenEditToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1665
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1666
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1667
extern GetNewsStringCallbackProc * const _get_news_string_callback[];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1668
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1669
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1670
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
  1671
{
1336
69391734ce23 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
  1672
	char buf[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1673
	StringID str;
1329
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  1674
	const char *s;
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  1675
	char *d;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1676
	DrawPixelInfo tmp_dpi, *old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1677
	int x;
1329
6988419aa6f0 (svn r1833) byte -> char transition: the rest
tron
parents: 1323
diff changeset
  1678
	char buffer[256];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1679
7854
8232d650df92 (svn r11404) -Codechange: remove 2 magical numbers
belugas
parents: 7849
diff changeset
  1680
	if (ni->display_mode == NM_CALLBACK) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1681
		str = _get_news_string_callback[ni->callback](ni);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1682
	} else {
7266
b16e67e992b4 (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7248
diff changeset
  1683
		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
  1684
		str = ni->string_id;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1685
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1686
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4907
diff changeset
  1687
	GetString(buf, str, lastof(buf));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1688
1336
69391734ce23 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1329
diff changeset
  1689
	s = buf;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1690
	d = buffer;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1691
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
  1692
	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
  1693
		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
  1694
		if (c == 0) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1695
			*d = '\0';
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1696
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1697
		} else if (*s == 0x0D) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1698
			d[0] = d[1] = d[2] = d[3] = ' ';
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1699
			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
  1700
		} 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
  1701
			d += Utf8Encode(d, c);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1702
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1703
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1704
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1705
	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
  1706
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1707
	old_dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1708
	_cur_dpi = &tmp_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1709
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
  1710
	x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1711
	_cur_dpi = old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1712
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1713
	return x > 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1714
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1715
410
0efd84450b01 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 395
diff changeset
  1716
static void StatusBarWndProc(Window *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1717
{
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
  1718
	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
  1719
	case WE_PAINT: {
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1720
		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
  1721
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1722
		DrawWindowWidgets(w);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
  1723
		SetDParam(0, _date);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1724
		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
  1725
			70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1726
		);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1727
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1728
		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
  1729
			/* 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
  1730
			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
  1731
			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
  1732
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1733
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
  1734
		/* 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
  1735
		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
  1736
			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
  1737
		} 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
  1738
			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
  1739
		} 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
  1740
			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
  1741
		} 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
  1742
			/* 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
  1743
			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
  1744
				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
  1745
				if (p != NULL) {
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1746
					/* This is the default text */
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1747
					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
  1748
					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
  1749
				}
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1750
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1751
		} else {
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1752
			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
  1753
				/* This is the default text */
7058
8105bb13ce3d (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents: 7056
diff changeset
  1754
				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
  1755
				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
  1756
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1757
		}
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
  1758
7359
35ecb2c98944 (svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents: 7357
diff changeset
  1759
		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
  1760
	} 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
  1761
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
  1762
	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
  1763
		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
  1764
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1765
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1766
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1767
	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
  1768
		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
  1769
			case 1: ShowLastNewsMessage(); break;
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
  1770
			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
  1771
			default: ResetObjectToPlace();
0
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
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1774
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1775
	case WE_TICK: {
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
  1776
		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
  1777
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
  1778
		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
  1779
			WP(w, def_d).data_1 -= 2;
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1780
			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
  1781
		}
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
  1782
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
  1783
		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
  1784
			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
  1785
		} 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
  1786
			WP(w, def_d).data_2 = 0;
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 7997
diff changeset
  1787
			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
  1788
		}
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
  1789
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1790
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1791
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1792
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1793
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1794
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1795
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
  1796
{      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
  1797
{    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
  1798
{    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
  1799
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1800
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1801
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1802
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
  1803
	WDP_CENTER, 0, 320, 12, 640, 12,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5890
diff changeset
  1804
	WC_STATUS_BAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1805
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1806
	_main_status_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1807
	StatusBarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1808
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1809
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  1810
extern void UpdateAllStationVirtCoord();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1811
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1812
static void MainWindowWndProc(Window *w, WindowEvent *e)
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4013
diff changeset
  1813
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1814
	int off_x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1815
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
  1816
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1817
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1818
		DrawWindowViewport(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1819
		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
  1820
			off_x = _screen.width / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1821
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  1822
			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
  1823
			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
  1824
			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
  1825
			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
  1826
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  1827
			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
  1828
			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
  1829
			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
  1830
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
  1831
			/*
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
  1832
			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
  1833
			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
  1834
			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
  1835
			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
  1836
			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
  1837
			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
  1838
			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
  1839
			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
  1840
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
  1841
			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
  1842
			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
  1843
			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
  1844
			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
  1845
			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
  1846
			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
  1847
			*/
0
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
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1850
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1851
	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
  1852
		switch (e->we.keypress.keycode) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1853
			case 'Q' | WKC_CTRL:
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1854
			case 'Q' | WKC_META:
4548
6165e12570bf (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
  1855
				HandleExitGameRequest();
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1856
				break;
2501
8d13d08b9232 (svn r3027) -Feature: [OSX] command+q now works in main menu (Tobin)
bjarni
parents: 2469
diff changeset
  1857
		}
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1397
diff changeset
  1858
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1859
		/* 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
  1860
		 * 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
  1861
		 * 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
  1862
		 * 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
  1863
		if (IsGeneratingWorld()) break;
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1864
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  1865
		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
  1866
			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
  1867
			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
  1868
			break;
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1869
		}
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1870
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
  1871
		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
  1872
			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
  1873
			_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
  1874
			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
  1875
			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
  1876
		}
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
  1877
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
  1878
		if (_game_mode == GM_MENU) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1879
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  1880
		switch (e->we.keypress.keycode) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1881
			case 'C':
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1882
			case 'Z': {
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1883
				Point pt = GetTileBelowCursor();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1884
				if (pt.x != -1) {
8176
b45860add89b (svn r11739) -Fix [FS#1609]: Set the new scroll position after zooming in instead of before, as the zoom will cancel it out.
peter1138
parents: 8157
diff changeset
  1885
					if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1886
					ScrollMainWindowTo(pt.x, pt.y);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1887
				}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1888
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1889
			}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1890
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1891
			case WKC_ESC: ResetObjectToPlace(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1892
			case WKC_DELETE: DeleteNonVitalWindows(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1893
			case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1894
			case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1895
1772
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
  1896
#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
  1897
			case '0' | WKC_ALT: // Crash the game
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1898
				*(byte*)0 = 0;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1899
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1900
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
  1901
			case '1' | WKC_ALT: // Gimme money
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1902
				/* Server can not cheat in advertise mode either! */
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1903
				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
  1904
					DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1905
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1906
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
  1907
			case '2' | WKC_ALT: // Update the coordinates of all station signs
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1908
				UpdateAllStationVirtCoord();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1909
				break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1910
#endif
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1911
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
  1912
			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
  1913
			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
  1914
			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
  1915
			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
  1916
			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
  1917
			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
  1918
			case '7' | WKC_CTRL:
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  1919
			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
  1920
				/* Transparency toggle hot keys */
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  1921
				ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1922
				MarkWholeScreenDirty();
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1923
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1924
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
  1925
			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
  1926
				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
  1927
				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
  1928
6494
b41e51f3c9ef (svn r9677) -Codechange: Make the 'transparent buildings' menu item toggle all transparency, to keep its old behaviour.
peter1138
parents: 6492
diff changeset
  1929
			case 'X':
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
  1930
				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
  1931
				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
  1932
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
  1933
#ifdef ENABLE_NETWORK
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1934
			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
  1935
				if (_networking) {
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1936
					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
  1937
					bool teamchat = false;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1938
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
  1939
					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
  1940
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1941
					/* 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
  1942
					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
  1943
						const NetworkClientInfo *ci;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1944
						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
  1945
							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
  1946
								teamchat = true;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1947
								break;
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1948
							}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1949
						}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1950
					}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1951
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
  1952
					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
  1953
				}
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1954
				break;
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1955
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1956
			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
  1957
				if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1958
				break;
4887
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1959
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1960
			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
  1961
				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
  1962
					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
  1963
					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
  1964
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
  1965
					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
  1966
				}
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
  1967
				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
  1968
#endif
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
  1969
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1970
			default: return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1971
		}
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4548
diff changeset
  1972
		e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1973
		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
  1974
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
  1975
		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
  1976
			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
  1977
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
  1978
			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
  1979
				_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
  1980
				_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
  1981
			}
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
  1982
6654
31d17823506f (svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents: 6626
diff changeset
  1983
			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
  1984
			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
  1985
			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
  1986
			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
  1987
		} 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
  1988
e705eef174bf (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
  1989
		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
  1990
			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
  1991
			break;
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1992
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1993
		case WE_MESSAGE:
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
  1994
			/* 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
  1995
			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
  1996
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1997
	}
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2000
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2001
void ShowSelectGameWindow();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2002
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2003
void SetupColorsAndInitialWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2004
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2005
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2006
	Window *w;
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
  2007
	int width, height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2008
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2009
	for (i = 0; i != 16; i++) {
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  2010
		const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i);
1357
0a4c07b68673 (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1350
diff changeset
  2011
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2012
		assert(b);
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4434
diff changeset
  2013
		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
  2014
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2015
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2016
	width = _screen.width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2017
	height = _screen.height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2018
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2019
	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
  2020
	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
  2021
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
  2022
	/* XXX: these are not done */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  2023
	switch (_game_mode) {
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2024
		default: NOT_REACHED();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2025
		case GM_MENU:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2026
			ShowSelectGameWindow();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2027
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2028
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2029
		case GM_NORMAL:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2030
		case GM_EDITOR:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2031
			ShowVitalWindows();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
  2032
			break;
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2035
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2036
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
  2037
{
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
  2038
	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
  2039
5048
b784951def0a (svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents: 5046
diff changeset
  2040
	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
  2041
	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
  2042
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
  2043
	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
  2044
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
  2045
	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
  2046
	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
  2047
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2048
	/* '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
  2049
	PositionMainToolbar(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2050
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2051
	/* Status bad only for normal games */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
  2052
	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
  2053
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
  2054
	_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
  2055
	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
  2056
	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
  2057
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8070
diff changeset
  2058
	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
  2059
}
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
  2060
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2061
void GameSizeChanged()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2062
{
2429
5e5b66fb8420 (svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents: 2361
diff changeset
  2063
	_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
  2064
	_cur_resolution[1] = _screen.height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2065
	RelocateAllWindows(_screen.width, _screen.height);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2066
	ScreenSizeChanged();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2067
	MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  2068
}
3622
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2069
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
  2070
void InitializeMainGui()
3622
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2071
{
730fd3cd0050 (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3469
diff changeset
  2072
	/* 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
  2073
	_last_built_railtype = RAILTYPE_RAIL;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6654
diff changeset
  2074
	_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
  2075
}
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5108
diff changeset
  2076
5237
4fce3ea379c2 (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 5235
diff changeset
  2077
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
  2078
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
8056
ae85cb9a770d (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents: 8036
diff changeset
  2080