src/toolbar_gui.cpp
author rubidium
Fri, 25 Apr 2008 06:15:58 +0000
changeset 10350 e08d68483283
parent 10281 85a77bfe5614
child 10433 cca9f7948fe5
permissions -rw-r--r--
(svn r12892) -Fix: too many items in the vehicle toolbars were greyed out.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
     3
/** @file toolbar_gui.cpp Code related to the (main) toolbar. */
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1885
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "window_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    10
#include "viewport_func.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    11
#include "command_func.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    12
#include "variables.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2652
diff changeset
    13
#include "train.h"
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7343
diff changeset
    14
#include "roadveh.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    15
#include "vehicle_gui.h"
8607
d16299e657ba (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8604
diff changeset
    16
#include "rail_gui.h"
d16299e657ba (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8604
diff changeset
    17
#include "road_gui.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8635
diff changeset
    18
#include "date_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    19
#include "vehicle_func.h"
8653
a83f7a536919 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8645
diff changeset
    20
#include "sound_func.h"
8701
051036216675 (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: 8692
diff changeset
    21
#include "terraform_gui.h"
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 8320
diff changeset
    22
#include "transparency.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8607
diff changeset
    23
#include "strings_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    24
#include "player_base.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    25
#include "player_func.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    26
#include "player_gui.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    27
#include "settings_type.h"
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    28
#include "toolbar_gui.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    29
#include "vehicle_base.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    30
#include "gfx_func.h"
10225
8becb17444a7 (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 9222
diff changeset
    31
#include "cheat_func.h"
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    32
#include "transparency_gui.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    33
#include "screenshot.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    34
#include "newgrf_config.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    35
#include "signs_func.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    36
#include "fios.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    37
#include "functions.h"
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    38
#include "console.h"
10237
f14be17a032a (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 10235
diff changeset
    39
#include "news_gui.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    41
#include "network/network.h"
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    42
#include "network/network_gui.h"
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    43
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    44
#include "table/strings.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    45
#include "table/sprites.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    47
static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    48
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
    49
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    50
RailType _last_built_railtype;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    51
RoadType _last_built_roadtype;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    52
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    53
static void SelectSignTool()
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    54
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    55
	if (_cursor.sprite == SPR_CURSOR_SIGN) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    56
		ResetObjectToPlace();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    57
	} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    58
		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    59
		_place_proc = PlaceProc_Sign;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    60
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    61
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    62
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    63
/** Returns the position where the toolbar wants the menu to appear.
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    64
 * Make sure the dropdown is fully visible within the window.
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    65
 * x + w->left because x is supposed to be the offset of the toolbar-button
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    66
 * we clicked on and w->left the toolbar window itself. So meaning that
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    67
 * the default position is aligned with the left side of the clicked button */
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    68
static Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    69
{
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
    70
	const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    71
	Point pos;
9222
7e175d5a9b4e (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 9219
diff changeset
    72
	pos.x = w->widget[GB(parent_button, 0, 8)].left;
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    73
	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
9222
7e175d5a9b4e (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 9219
diff changeset
    74
	pos.y = w->height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    76
	return pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    79
/* --- Pausing --- */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
static void ToolbarPauseClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
    83
	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
    84
6557
8381016f71f3 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6527
diff changeset
    85
	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
    86
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    88
/* --- Fast forwarding --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    89
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
static void ToolbarFastForwardClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	_fast_forward ^= true;
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
    93
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
    96
/* --- Options button menu --- */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
static void ToolbarOptionsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
{
4822
ff5230aeb132 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   100
	uint16 x = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
8920
04df97185061 (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: 8766
diff changeset
   102
	w = PopupMainToolbMenu(w, 2, STR_02C4_GAME_OPTIONS, 14, 0);
7511
ddbac631dc6d (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: 7498
diff changeset
   103
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   104
	if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES))    SetBit(x,  6);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   105
	if (HasBit(_display_opt, DO_SHOW_STATION_NAMES)) SetBit(x,  7);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   106
	if (HasBit(_display_opt, DO_SHOW_SIGNS))         SetBit(x,  8);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   107
	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   108
	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   109
	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
9111
7f882e1856c2 (svn r12198) -Fix [FS#1789]: "Transparent buildings" now only toggles buildings, so show tick when buildings are transparent.
peter1138
parents: 9080
diff changeset
   110
	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
7f882e1856c2 (svn r12198) -Fix [FS#1789]: "Transparent buildings" now only toggles buildings, so show tick when buildings are transparent.
peter1138
parents: 9080
diff changeset
   111
	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8566
diff changeset
   112
	WP(w, menu_d).checked_items = x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   115
static void MenuClickSettings(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   116
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   117
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   118
		case 0: ShowGameOptions();      return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   119
		case 1: ShowGameDifficulty();   return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   120
		case 2: ShowPatchesSelection(); return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   121
		case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig);   return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   122
		case 4: ShowTransparencyToolbar(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   123
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   124
		case  6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES);    break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   125
		case  7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   126
		case  8: ToggleBit(_display_opt, DO_SHOW_SIGNS);         break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   127
		case  9: ToggleBit(_display_opt, DO_WAYPOINTS);          break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   128
		case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION);     break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   129
		case 11: ToggleBit(_display_opt, DO_FULL_DETAIL);        break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   130
		case 12: ToggleTransparency(TO_HOUSES);                  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   131
		case 13: ToggleTransparency(TO_SIGNS);                   break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   132
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   133
	MarkWholeScreenDirty();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   134
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   135
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   136
/* --- Saving/loading button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   137
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   138
static void ToolbarSaveClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   139
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   140
	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   141
}
0
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
static void ToolbarScenSaveOrLoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
{
6145
d34703513ed0 (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: 6144
diff changeset
   145
	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
   146
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   148
static void MenuClickSaveLoad(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   149
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   150
	if (_game_mode == GM_EDITOR) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   151
		switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   152
			case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO);  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   153
			case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO);  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   154
			case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   155
			case 3: AskExitToGameMenu();                    break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   156
			case 5: HandleExitGameRequest();                break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   157
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   158
	} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   159
		switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   160
			case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   161
			case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   162
			case 2: AskExitToGameMenu();               break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   163
			case 3: HandleExitGameRequest();           break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   164
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   165
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   166
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   167
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   168
/* --- Map button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   169
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   170
static void ToolbarMapClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   171
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   172
	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   173
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   174
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   175
static void MenuClickMap(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   176
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   177
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   178
		case 0: ShowSmallMap();            break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   179
		case 1: ShowExtraViewPortWindow(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   180
		case 2: ShowSignList();            break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   181
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   182
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   183
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   184
static void MenuClickScenMap(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   185
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   186
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   187
		case 0: ShowSmallMap();            break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   188
		case 1: ShowExtraViewPortWindow(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   189
		case 2: ShowSignList();            break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   190
		case 3: ShowTownDirectory();       break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   191
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   192
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   193
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   194
/* --- Town button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   195
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   196
static void ToolbarTownClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   197
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   198
	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   199
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   200
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   201
static void MenuClickTown(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   202
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   203
	ShowTownDirectory();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   204
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   205
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   206
/* --- Subidies button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   207
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   208
static void ToolbarSubsidiesClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   209
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   210
	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   211
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   212
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   213
static void MenuClickSubsidies(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   214
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   215
	ShowSubsidiesList();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   216
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   217
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   218
/* --- Stations button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   219
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   220
static void ToolbarStationsClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   221
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   222
	PopupMainPlayerToolbMenu(w, 7, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   223
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   224
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   225
static void MenuClickStations(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   226
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   227
	ShowPlayerStations((PlayerID)index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   228
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   229
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   230
/* --- Finances button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   231
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   232
static void ToolbarFinancesClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   233
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   234
	PopupMainPlayerToolbMenu(w, 8, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   235
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   236
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   237
static void MenuClickFinances(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   238
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   239
	ShowPlayerFinances((PlayerID)index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   240
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   241
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   242
/* --- Company's button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   243
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   244
static void ToolbarPlayersClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   245
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   246
	PopupMainPlayerToolbMenu(w, 9, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   247
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   248
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   249
static void MenuClickCompany(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   250
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   251
	if (_networking && index == 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   252
		ShowClientList();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   253
	} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   254
		if (_networking) index--;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   255
		ShowPlayerCompany((PlayerID)index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   256
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   257
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   258
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   259
/* --- Graphs button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   260
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   261
static void ToolbarGraphsClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   262
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   263
	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   264
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   265
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   266
static void MenuClickGraphs(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   267
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   268
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   269
		case 0: ShowOperatingProfitGraph();    break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   270
		case 1: ShowIncomeGraph();             break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   271
		case 2: ShowDeliveredCargoGraph();     break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   272
		case 3: ShowPerformanceHistoryGraph(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   273
		case 4: ShowCompanyValueGraph();       break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   274
		case 5: ShowCargoPaymentRates();       break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   275
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   276
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   277
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   278
/* --- League button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   279
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   280
static void ToolbarLeagueClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   281
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   282
	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   283
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   284
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   285
static void MenuClickLeague(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   286
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   287
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   288
		case 0: ShowCompanyLeagueTable();      break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   289
		case 1: ShowPerformanceRatingDetail(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   290
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   291
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   292
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   293
/* --- Industries button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   294
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   295
static void ToolbarIndustryClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   296
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   297
	/* Disable build-industry menu if we are a spectator */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   298
	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   299
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   300
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   301
static void MenuClickIndustry(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   302
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   303
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   304
		case 0: ShowIndustryDirectory();   break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   305
		case 1: ShowBuildIndustryWindow(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   306
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   307
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   308
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   309
/* --- Trains button menu + 1 helper function for all vehicles. --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   310
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   311
static void ToolbarVehicleClick(Window *w, VehicleType veh)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   312
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   313
	const Vehicle *v;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   314
	int dis = ~0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   315
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   316
	FOR_ALL_VEHICLES(v) {
10350
e08d68483283 (svn r12892) -Fix: too many items in the vehicle toolbars were greyed out.
rubidium
parents: 10281
diff changeset
   317
		if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   318
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   319
	PopupMainPlayerToolbMenu(w, 13 + veh, dis);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   320
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   321
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   322
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   323
static void ToolbarTrainClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   324
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   325
	ToolbarVehicleClick(w, VEH_TRAIN);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   326
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   327
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   328
static void MenuClickShowTrains(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   329
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   330
	ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   331
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   332
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   333
/* --- Road vehicle button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   334
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   335
static void ToolbarRoadClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   336
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   337
	ToolbarVehicleClick(w, VEH_ROAD);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   338
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   339
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   340
static void MenuClickShowRoad(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   341
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   342
	ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   343
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   344
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   345
/* --- Ship button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   346
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   347
static void ToolbarShipClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   348
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   349
	ToolbarVehicleClick(w, VEH_SHIP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   350
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   351
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   352
static void MenuClickShowShips(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   353
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   354
	ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   355
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   356
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   357
/* --- Aircraft button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   358
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   359
static void ToolbarAirClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   360
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   361
	ToolbarVehicleClick(w, VEH_AIRCRAFT);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   362
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   363
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   364
static void MenuClickShowAir(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   365
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   366
	ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   367
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   368
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   369
/* --- Zoom in button --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   370
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   371
static void ToolbarZoomInClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   372
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   373
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   374
		w->HandleButtonClick(17);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   375
		SndPlayFx(SND_15_BEEP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   376
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   377
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   378
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   379
/* --- Zoom out button --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   380
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   381
static void ToolbarZoomOutClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   382
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   383
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   384
		w->HandleButtonClick(18);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   385
		SndPlayFx(SND_15_BEEP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   386
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   387
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   388
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   389
/* --- Rail button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   390
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   391
static void ToolbarBuildRailClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   392
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   393
	const Player *p = GetPlayer(_local_player);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   394
	Window *w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   395
	WP(w2, menu_d).sel_index = _last_built_railtype;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   396
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   397
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   398
static void MenuClickBuildRail(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   399
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   400
	_last_built_railtype = (RailType)index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   401
	ShowBuildRailToolbar(_last_built_railtype, -1);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   402
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   403
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   404
/* --- Road button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   405
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   406
static void ToolbarBuildRoadClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   407
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   408
	const Player *p = GetPlayer(_local_player);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   409
	/* The standard road button is *always* available */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   410
	Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   411
	WP(w2, menu_d).sel_index = _last_built_roadtype;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   412
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   413
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   414
static void MenuClickBuildRoad(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   415
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   416
	_last_built_roadtype = (RoadType)index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   417
	ShowBuildRoadToolbar(_last_built_roadtype);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   418
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   419
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   420
/* --- Water button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   421
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   422
static void ToolbarBuildWaterClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   423
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   424
	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   425
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   426
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   427
static void MenuClickBuildWater(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   428
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   429
	ShowBuildDocksToolbar();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   430
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   431
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   432
/* --- Airport button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   433
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   434
static void ToolbarBuildAirClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   435
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   436
	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   437
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   438
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   439
static void MenuClickBuildAir(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   440
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   441
	ShowBuildAirToolbar();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   442
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   443
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   444
/* --- Forest button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   445
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   446
static void ToolbarForestClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   447
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   448
	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   449
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   450
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   451
static void MenuClickForest(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   452
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   453
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   454
		case 0: ShowTerraformToolbar();  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   455
		case 1: ShowBuildTreesToolbar(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   456
		case 2: SelectSignTool();        break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   457
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   458
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   459
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   460
/* --- Music button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   461
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   462
static void ToolbarMusicClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   463
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   464
	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   465
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   466
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   467
static void MenuClickMusicWindow(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   468
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   469
	ShowMusicWindow();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   470
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   471
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   472
/* --- Newspaper button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   473
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   474
static void ToolbarNewspaperClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   475
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   476
	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   477
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   478
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   479
static void MenuClickNewspaper(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   480
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   481
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   482
		case 0: ShowLastNewsMessage(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   483
		case 1: ShowMessageOptions();  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   484
		case 2: ShowMessageHistory();  break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   485
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   486
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   487
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   488
/* --- Help button menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   489
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   490
static void ToolbarHelpClick(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   491
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   492
	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   493
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   494
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   495
static void MenuClickSmallScreenshot()
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   496
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   497
	SetScreenshotType(SC_VIEWPORT);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   498
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   499
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   500
static void MenuClickWorldScreenshot()
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   501
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   502
	SetScreenshotType(SC_WORLD);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   503
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   504
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   505
static void MenuClickHelp(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   506
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   507
	switch (index) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   508
		case 0: PlaceLandBlockInfo();       break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   509
		case 2: IConsoleSwitch();           break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   510
		case 3: MenuClickSmallScreenshot(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   511
		case 4: MenuClickWorldScreenshot(); break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   512
		case 5: ShowAboutWindow();          break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   513
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   514
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   515
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   516
/* --- Scenario editor specific handlers. */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   517
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
static void ToolbarScenDateBackward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
{
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
   520
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   522
		w->HandleButtonClick(6);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   523
		SetWindowDirty(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   524
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   525
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   526
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
static void ToolbarScenDateForward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
{
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
   533
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   535
		w->HandleButtonClick(7);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   536
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   538
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   539
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
static void ToolbarScenMapTownDir(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   546
	/* Scenario editor button, *hack*hack* use different button to activate */
7621
5a724720444c (svn r10398) -Fix (r10271): transparency menu option wasn't moved properly in the scenario editor
peter1138
parents: 7582
diff changeset
   547
	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
   548
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
static void ToolbarScenZoomIn(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
{
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
   552
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   553
		w->HandleButtonClick(9);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   554
		SndPlayFx(SND_15_BEEP);
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
static void ToolbarScenZoomOut(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
{
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
   560
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   561
		w->HandleButtonClick(10);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   562
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
}
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
static void ToolbarScenGenLand(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   568
	w->HandleButtonClick(11);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   569
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
8701
051036216675 (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: 8692
diff changeset
   571
	ShowEditorTerraformToolbar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
static void ToolbarScenGenTown(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   577
	w->HandleButtonClick(12);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   578
	SndPlayFx(SND_15_BEEP);
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   579
	ShowBuildTownWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
static void ToolbarScenGenIndustry(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   584
	w->HandleButtonClick(13);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   585
	SndPlayFx(SND_15_BEEP);
7714
d2060492ca03 (svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
belugas
parents: 7698
diff changeset
   586
	ShowBuildIndustryWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
static void ToolbarScenBuildRoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   591
	w->HandleButtonClick(14);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   592
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
	ShowBuildRoadScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
static void ToolbarScenPlantTrees(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   598
	w->HandleButtonClick(15);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   599
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	ShowBuildTreesScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
static void ToolbarScenPlaceSign(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   605
	w->HandleButtonClick(16);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   606
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
	SelectSignTool();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
static void ToolbarBtn_NULL(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   614
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   615
/* --- Toolbar handling for the 'normal' case */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   616
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   617
typedef void ToolbarButtonProc(Window *w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   618
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   619
static ToolbarButtonProc * const _toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
	ToolbarSaveClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
	ToolbarMapClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
	ToolbarTownClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
	ToolbarSubsidiesClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
	ToolbarStationsClick,
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   628
	ToolbarFinancesClick,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
	ToolbarPlayersClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
	ToolbarGraphsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
	ToolbarLeagueClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
	ToolbarIndustryClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
	ToolbarTrainClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
	ToolbarRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
	ToolbarShipClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
	ToolbarAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
	ToolbarZoomInClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
	ToolbarZoomOutClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
	ToolbarBuildRailClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
	ToolbarBuildRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
	ToolbarBuildWaterClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
	ToolbarBuildAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
	ToolbarForestClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
	ToolbarNewspaperClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   649
static void MainToolbarWndProc(Window *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   651
	switch (e->event) {
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   652
		case WE_PAINT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   653
			/* Draw brown-red toolbar bg. */
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
   654
			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB2);
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
   655
			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
   656
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   657
			/* If spectator, disable all construction buttons
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   658
			* ie : Build road, rail, ships, airports and landscaping
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   659
			* Since enabled state is the default, just disable when needed */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   660
			w->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   661
			/* disable company list drop downs, if there are no companies */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   662
			w->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   663
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   664
			w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   665
			w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   666
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   667
			DrawWindowWidgets(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   668
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   670
		case WE_CLICK:
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   671
			if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget)) _toolbar_button_procs[e->we.click.widget](w);
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   672
			break;
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   673
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   674
		case WE_KEYPRESS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   675
			switch (e->we.keypress.keycode) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   676
				case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   677
				case WKC_F2: ShowGameOptions(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   678
				case WKC_F3: MenuClickSaveLoad(0); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   679
				case WKC_F4: ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   680
				case WKC_F5: ShowTownDirectory(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   681
				case WKC_F6: ShowSubsidiesList(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   682
				case WKC_F7: ShowPlayerStations(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   683
				case WKC_F8: ShowPlayerFinances(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   684
				case WKC_F9: ShowPlayerCompany(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   685
				case WKC_F10: ShowOperatingProfitGraph(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   686
				case WKC_F11: ShowCompanyLeagueTable(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   687
				case WKC_F12: ShowBuildIndustryWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   688
				case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_TRAIN); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   689
				case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_ROAD); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   690
				case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_SHIP); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   691
				case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_AIRCRAFT); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   692
				case WKC_NUM_PLUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   693
				case WKC_EQUALS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   694
				case WKC_SHIFT | WKC_EQUALS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   695
				case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   696
				case WKC_NUM_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   697
				case WKC_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   698
				case WKC_SHIFT | WKC_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   699
				case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   700
				case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   701
				case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   702
				case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   703
				case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   704
				case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   705
				case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   706
				case WKC_CTRL  | 'S': MenuClickSmallScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   707
				case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   708
				case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   709
				case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   710
				case 'L': ShowTerraformToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   711
				case 'M': ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   712
				case 'V': ShowExtraViewPortWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   713
				default: return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   714
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   715
			e->we.keypress.cont = false;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   716
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   717
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   718
		case WE_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   719
			_place_proc(e->we.place.tile);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   720
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   721
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   722
		case WE_ABORT_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   723
			w->RaiseWidget(25);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   724
			SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   725
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   726
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   727
		case WE_MOUSELOOP:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   728
			if (w->IsWidgetLowered(0) != !!_pause_game) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   729
				w->ToggleWidgetLoweredState(0);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   730
				w->InvalidateWidget(0);
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   731
			}
7857
105eabc8fe1a (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7856
diff changeset
   732
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   733
			if (w->IsWidgetLowered(1) != !!_fast_forward) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   734
				w->ToggleWidgetLoweredState(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   735
				w->InvalidateWidget(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   736
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   737
			break;
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   738
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   739
		case WE_RESIZE: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   740
			/* There are 27 buttons plus some spacings if the space allows it */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   741
			uint button_width;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   742
			uint spacing;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   743
			if (w->width >= 27 * 22) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   744
				button_width = 22;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   745
				spacing = w->width - (27 * button_width);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   746
			} else {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   747
				button_width = w->width / 27;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   748
				spacing = 0;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   749
			}
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   750
			uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   751
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   752
			for (uint i = 0, x = 0, j = 0; i < 27; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   753
				if (extra_spacing_at[j] == i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   754
					j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   755
					uint add = spacing / (lengthof(extra_spacing_at) - j);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   756
					spacing -= add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   757
					x += add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   758
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   759
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   760
				w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   761
				x += (spacing != 0) ? button_width : (w->width - x) / (27 - i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   762
				w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   763
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   764
		} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   765
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   766
		case WE_TIMEOUT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   767
			for (uint i = 2; i < w->widget_count; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   768
				if (w->IsWidgetLowered(i)) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   769
					w->RaiseWidget(i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   770
					w->InvalidateWidget(i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   771
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   772
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   773
			break;
5045
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   774
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   775
		case WE_MESSAGE:
7744
a1c9caef2a8d (svn r10548) -Fix [FS#1020]: don't segfault when you quit in the end-of-the-game screen
truelight
parents: 7714
diff changeset
   776
			if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
5045
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   777
			break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   778
	}
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 const Widget _toolb_normal_widgets[] = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   782
{     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   783
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   784
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   785
{   WWT_IMGBTN_2,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   786
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   787
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   788
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   789
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   790
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   791
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   792
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   793
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   794
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   795
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   796
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   797
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   798
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   799
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   800
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   801
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   802
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   803
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   804
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   805
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   806
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   807
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   808
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   809
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   810
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_LANDSCAPING,     STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   811
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   812
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   813
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   814
{     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
   815
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
static const WindowDesc _toolb_normal_desc = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   819
	0, 0, 0, 22, 640, 22,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6141
diff changeset
   820
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
	_toolb_normal_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
	MainToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   825
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   827
/* --- Toolbar handling for the scenario editor */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   828
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   829
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   830
	ToolbarPauseClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   831
	ToolbarFastForwardClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   832
	ToolbarOptionsClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   833
	ToolbarScenSaveOrLoad,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   834
	ToolbarBtn_NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   835
	ToolbarBtn_NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   836
	ToolbarScenDateBackward,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   837
	ToolbarScenDateForward,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   838
	ToolbarScenMapTownDir,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   839
	ToolbarScenZoomIn,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   840
	ToolbarScenZoomOut,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   841
	ToolbarScenGenLand,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   842
	ToolbarScenGenTown,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   843
	ToolbarScenGenIndustry,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   844
	ToolbarScenBuildRoad,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   845
	ToolbarScenPlantTrees,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   846
	ToolbarScenPlaceSign,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   847
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   848
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   849
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   850
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   851
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   852
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   853
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   854
	ToolbarMusicClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   855
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   856
	ToolbarHelpClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   857
};
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   858
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
   859
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   860
{
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   861
	switch (e->event) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   862
		case WE_PAINT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   863
			w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   864
			w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   865
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   866
			/* Draw brown-red toolbar bg. */
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
   867
			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB2);
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
   868
			GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   869
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   870
			DrawWindowWidgets(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   871
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   872
			SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   873
			DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   874
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   875
			/* We hide this panel when the toolbar space gets too small */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   876
			if (w->widget[4].left != w->widget[4].right) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   877
				DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   878
				DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   879
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   880
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   881
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   882
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   883
		case WE_CLICK:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   884
			if (_game_mode == GM_MENU) return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   885
			_scen_toolbar_button_procs[e->we.click.widget](w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   886
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   887
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   888
		case WE_KEYPRESS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   889
			switch (e->we.keypress.keycode) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   890
				case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   891
				case WKC_F2: ShowGameOptions(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   892
				case WKC_F3: MenuClickSaveLoad(0); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   893
				case WKC_F4: ToolbarScenGenLand(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   894
				case WKC_F5: ToolbarScenGenTown(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   895
				case WKC_F6: ToolbarScenGenIndustry(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   896
				case WKC_F7: ToolbarScenBuildRoad(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   897
				case WKC_F8: ToolbarScenPlantTrees(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   898
				case WKC_F9: ToolbarScenPlaceSign(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   899
				case WKC_F10: ShowMusicWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   900
				case WKC_F11: PlaceLandBlockInfo(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   901
				case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   902
				case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   903
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   904
				/* those following are all fall through */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   905
				case WKC_NUM_PLUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   906
				case WKC_EQUALS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   907
				case WKC_SHIFT | WKC_EQUALS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   908
				case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   909
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   910
				/* those following are all fall through */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   911
				case WKC_NUM_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   912
				case WKC_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   913
				case WKC_SHIFT | WKC_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   914
				case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   915
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   916
				case 'L': ShowEditorTerraformToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   917
				case 'M': ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   918
				case 'V': ShowExtraViewPortWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   919
				default: return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   920
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   921
			e->we.keypress.cont = false;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   922
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   923
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   924
		case WE_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   925
			_place_proc(e->we.place.tile);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   926
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   927
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   928
		case WE_ABORT_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   929
			w->RaiseWidget(25);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   930
			SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   931
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   932
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   933
		case WE_RESIZE: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   934
			/* There are 15 buttons plus some spacings if the space allows it.
10229
fba3f9fa44d7 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 10225
diff changeset
   935
			* Furthermore there are two panels of which one is non - essential
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   936
			* and that one can be removed is the space is too small. */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   937
			uint buttons_width;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   938
			uint spacing;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   939
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   940
			static int normal_min_width = (15 * 22) + (2 * 130);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   941
			static int one_less_panel_min_width = (15 * 22) + 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   942
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   943
			if (w->width >= one_less_panel_min_width) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   944
				buttons_width = 15 * 22;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   945
				spacing = w->width - ((w->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   946
			} else {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   947
				buttons_width = w->width - 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   948
				spacing = 0;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   949
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   950
			uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 16, 0 };
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   951
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   952
			/* Yes, it defines about 27 widgets for this toolbar */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   953
			for (uint i = 0, x = 0, j = 0, b = 0; i < 27; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   954
				switch (i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   955
					case 4:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   956
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   957
						if (w->width < normal_min_width) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   958
							w->widget[i].right = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   959
							j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   960
							continue;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   961
						}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   962
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   963
						x += 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   964
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   965
						break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   966
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   967
					case 5: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   968
						int offset = x - w->widget[i].left;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   969
						w->widget[i + 1].left  += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   970
						w->widget[i + 1].right += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   971
						w->widget[i + 2].left  += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   972
						w->widget[i + 2].right += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   973
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   974
						x += 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   975
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   976
						i += 2;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   977
					} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   978
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   979
					default:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   980
						if (w->widget[i].bottom == 0) continue;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   981
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   982
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   983
						x += buttons_width / (15 - b);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   984
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   985
						buttons_width -= buttons_width / (15 - b);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   986
						b++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   987
						break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   988
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   989
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   990
				if (extra_spacing_at[j] == i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   991
					j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   992
					uint add = spacing / (lengthof(extra_spacing_at) - j);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   993
					spacing -= add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   994
					x += add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   995
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   996
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   997
		} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   998
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   999
		case WE_MOUSELOOP:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1000
			if (w->IsWidgetLowered(0) != !!_pause_game) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1001
				w->ToggleWidgetLoweredState(0);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1002
				SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1003
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1004
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1005
			if (w->IsWidgetLowered(1) != !!_fast_forward) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1006
				w->ToggleWidgetLoweredState(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1007
				SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1008
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1009
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1010
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1011
		case WE_MESSAGE:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1012
			HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1013
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1014
	}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1015
}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1016
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
static const Widget _toolb_scen_widgets[] = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1018
{  WWT_IMGBTN, RESIZE_LEFT, 14,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1019
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1020
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1021
{WWT_IMGBTN_2, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1022
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1023
{   WWT_PANEL, RESIZE_NONE, 14,   0,   0,  0, 21, 0x0,                 STR_NULL},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1024
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1025
{   WWT_PANEL, RESIZE_NONE, 14,   0, 129,  0, 21, 0x0,                 STR_NULL},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1026
{  WWT_IMGBTN, RESIZE_NONE, 14,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1027
{  WWT_IMGBTN, RESIZE_NONE, 14, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1028
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1029
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1030
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1031
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1032
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1033
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1034
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1035
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1036
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1037
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1038
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1039
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1040
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1041
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1042
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1043
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1044
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1045
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1046
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1047
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1048
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
  1049
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1050
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_QUERY,       STR_0186_LAND_BLOCK_INFORMATION},
3248
3efa415f68f1 (svn r3931) - [ 1451726 ] Use sprite names in main_gui.c instead of numbers (matthewwalton)
Darkvater
parents: 3182
diff changeset
  1051
{WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
static const WindowDesc _toolb_scen_desc = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
  1055
	0, 0, 130, 22, 640, 22,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6141
diff changeset
  1056
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1057
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
	_toolb_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1059
	ScenEditToolbarWndProc
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
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1062
/* --- Rendering/handling the drop down menus --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1063
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1064
typedef void MenuClickedProc(int index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1065
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1066
static MenuClickedProc * const _menu_clicked_procs[] = {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1067
	NULL,                 /* 0 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1068
	NULL,                 /* 1 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1069
	MenuClickSettings,    /* 2 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1070
	MenuClickSaveLoad,    /* 3 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1071
	MenuClickMap,         /* 4 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1072
	MenuClickTown,        /* 5 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1073
	MenuClickSubsidies,   /* 6 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1074
	MenuClickStations,    /* 7 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1075
	MenuClickFinances,    /* 8 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1076
	MenuClickCompany,     /* 9 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1077
	MenuClickGraphs,      /* 10 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1078
	MenuClickLeague,      /* 11 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1079
	MenuClickIndustry,    /* 12 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1080
	MenuClickShowTrains,  /* 13 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1081
	MenuClickShowRoad,    /* 14 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1082
	MenuClickShowShips,   /* 15 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1083
	MenuClickShowAir,     /* 16 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1084
	MenuClickScenMap,     /* 17 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1085
	NULL,                 /* 18 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1086
	MenuClickBuildRail,   /* 19 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1087
	MenuClickBuildRoad,   /* 20 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1088
	MenuClickBuildWater,  /* 21 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1089
	MenuClickBuildAir,    /* 22 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1090
	MenuClickForest,      /* 23 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1091
	MenuClickMusicWindow, /* 24 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1092
	MenuClickNewspaper,   /* 25 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1093
	MenuClickHelp,        /* 26 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1094
};
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1095
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1096
static void MenuWndProc(Window *w, WindowEvent *e)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1097
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1098
	switch (e->event) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1099
		case WE_CREATE:
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1100
			w->widget[0].right = w->width - 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1101
			break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1102
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1103
		case WE_PAINT: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1104
			byte count = WP(w, menu_d).item_count;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1105
			byte sel = WP(w, menu_d).sel_index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1106
			uint16 chk = WP(w, menu_d).checked_items;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1107
			StringID string = WP(w, menu_d).string_id;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1108
			byte dis = WP(w, menu_d).disabled_items;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1109
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1110
			DrawWindowWidgets(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1111
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1112
			int x = 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1113
			int y = 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1114
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1115
			for (; count != 0; count--, string++, sel--) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1116
				TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1117
				if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1118
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1119
				if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1120
				DrawString(x + 2, y, string, color);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1121
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1122
				y += 10;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1123
				chk >>= 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1124
				dis >>= 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1125
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1126
		} break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1127
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1128
		case WE_DESTROY: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1129
				Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1130
				v->RaiseWidget(WP(w, menu_d).main_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1131
				SetWindowDirty(v);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1132
				return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1133
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1134
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1135
		case WE_POPUPMENU_SELECT: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1136
			int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1137
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1138
			if (index < 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1139
				Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1140
				if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1141
					index = WP(w, menu_d).sel_index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1142
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1143
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1144
			int action_id = WP(w, menu_d).action_id;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1145
			DeleteWindow(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1146
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1147
			if (index >= 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1148
				assert((uint)index <= lengthof(_menu_clicked_procs));
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1149
				_menu_clicked_procs[action_id](index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1150
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1151
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1152
		} break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1153
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1154
		case WE_POPUPMENU_OVER: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1155
			int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1156
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1157
			if (index == -1 || index == WP(w, menu_d).sel_index) return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1158
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1159
			WP(w, menu_d).sel_index = index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1160
			SetWindowDirty(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1161
			return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1162
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1163
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1164
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1165
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1166
/* Dynamic widget length determined by toolbar-string length.
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1167
 * See PopupMainToolbMenu en MenuWndProc */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1168
static const Widget _menu_widgets[] = {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1169
{    WWT_PANEL, RESIZE_NONE, 14, 0,  0, 0, 0, 0x0, STR_NULL},
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1170
{ WIDGETS_END},
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1171
};
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1172
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1173
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1174
/**
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1175
 * Get the maximum length of a given string in a string-list. This is an
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1176
 * implicit string-list where the ID's are consecutive
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1177
 * @param base_string StringID of the first string in the list
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1178
 * @param count amount of StringID's in the list
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1179
 * @return the length of the longest string
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1180
 */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1181
static int GetStringListMaxWidth(StringID base_string, byte count)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1182
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1183
	char buffer[512];
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1184
	int width, max_width = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1185
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1186
	for (byte i = 0; i != count; i++) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1187
		GetString(buffer, base_string + i, lastof(buffer));
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1188
		width = GetStringBoundingBox(buffer).width;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1189
		if (width > max_width) max_width = width;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1190
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1191
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1192
	return max_width;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1193
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1194
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1195
/**
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1196
 * Show a general dropdown menu. The positioning of the dropdown menu
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1197
 * defaults to the left side of the parent_button, eg the button that caused
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1198
 * this window to appear. The only exceptions are when the right side of this
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1199
 * dropdown would fall outside the main toolbar window, in that case it is
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1200
 * aligned with the toolbar's right side.
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1201
 * Since the disable-mask is only 8 bits right now, these dropdowns are
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1202
 * restricted to 8 items max if any bits of disabled_mask are active.
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1203
 * @param w Pointer to a window this dropdown menu belongs to. Has no effect
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1204
 * whatsoever, only graphically for positioning.
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1205
 * @param parent_button The widget identifier of the button that was clicked for
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1206
 * this dropdown. The created dropdown then knows what button to raise (button) on
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1207
 * action and whose function to execute (action).
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1208
 * It is possible to appoint another button for an action event by setting the
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1209
 * upper 8 bits of this parameter. If non is set, action is presumed to be the same
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1210
 * as button. So<br>
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1211
 * button bits 0 -  7 - widget clicked to get dropdown
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1212
 * action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1213
 * @param base_string The first StringID shown in the dropdown list. All others are
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1214
 * consecutive indeces from the language file. XXX - fix? Use ingame-string tables?
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1215
 * @param item_count Number of strings in the list, see previous parameter
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1216
 * @param disabled_mask Bitmask of disabled strings in the list
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1217
 * @return Return a pointer to the newly created dropdown window */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1218
static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1219
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1220
	assert(disabled_mask == 0 || item_count <= 8);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1221
	w->LowerWidget(parent_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1222
	w->InvalidateWidget(parent_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1223
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1224
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1225
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1226
	/* Extend the dropdown toolbar to the longest string in the list */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1227
	int width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1228
	int height = item_count * 10 + 2;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1229
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1230
	Point pos = GetToolbarDropdownPos(parent_button, width, height);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1231
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1232
	w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1233
	w->widget[0].bottom = item_count * 10 + 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1234
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1236
	WP(w, menu_d).item_count = item_count;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1237
	WP(w, menu_d).sel_index = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1238
	WP(w, menu_d).main_button = GB(parent_button, 0, 8);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1239
	WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1240
	WP(w, menu_d).string_id = base_string;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1241
	WP(w, menu_d).checked_items = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1242
	WP(w, menu_d).disabled_items = disabled_mask;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1243
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1244
	_popup_menu_active = true;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1245
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1246
	SndPlayFx(SND_15_BEEP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1247
	return w;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1248
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1249
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1250
/* --- Rendering/drawing the player menu --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1251
static int GetPlayerIndexFromMenu(int index)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1252
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1253
	if (index >= 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1254
		const Player *p;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1255
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1256
		FOR_ALL_PLAYERS(p) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1257
			if (p->is_active && --index < 0) return p->index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1258
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1259
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1260
	return -1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1261
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1262
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1263
static void UpdatePlayerMenuHeight(Window *w)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1264
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1265
	byte num = ActivePlayerCount();
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1266
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1267
	/* Increase one to fit in PlayerList in the menu when in network */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1268
	if (_networking && WP(w, menu_d).main_button == 9) num++;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1269
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1270
	if (WP(w, menu_d).item_count != num) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1271
		WP(w, menu_d).item_count = num;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1272
		SetWindowDirty(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1273
		num = num * 10 + 2;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1274
		w->height = num;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1275
		w->widget[0].bottom = w->widget[0].top + num - 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1276
		w->top = GetToolbarDropdownPos(0, w->width, w->height).y;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1277
		SetWindowDirty(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1278
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1279
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1280
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1281
static void PlayerMenuWndProc(Window *w, WindowEvent *e)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1282
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1283
	switch (e->event) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1284
		case WE_PAINT: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1285
			UpdatePlayerMenuHeight(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1286
			DrawWindowWidgets(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1287
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1288
			int x = 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1289
			int y = 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1290
			int sel = WP(w, menu_d).sel_index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1291
			int chk = WP(w, menu_d).checked_items; // let this mean gray items.
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1292
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1293
			/* 9 = playerlist */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1294
			if (_networking && WP(w, menu_d).main_button == 9) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1295
				if (sel == 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1296
					GfxFillRect(x, y, x + 238, y + 9, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1297
				}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1298
				DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1299
				y += 10;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1300
				sel--;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1301
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1302
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1303
			const Player *p;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1304
			FOR_ALL_PLAYERS(p) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1305
				if (p->is_active) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1306
					if (p->index == sel) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1307
						GfxFillRect(x, y, x + 238, y + 9, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1308
					}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1309
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1310
					DrawPlayerIcon(p->index, x + 2, y + 1);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1311
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1312
					SetDParam(0, p->index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1313
					SetDParam(1, p->index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1314
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1315
					TextColour color = (p->index == sel) ? TC_WHITE : TC_BLACK;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1316
					if (chk & 1) color = TC_GREY;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1317
					DrawString(x + 19, y, STR_7021, color);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1318
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1319
					y += 10;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1320
				}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1321
				chk >>= 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1322
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1323
		 } break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1324
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1325
		case WE_DESTROY: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1326
			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1327
			v->RaiseWidget(WP(w, menu_d).main_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1328
			SetWindowDirty(v);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1329
			return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1330
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1331
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1332
		case WE_POPUPMENU_SELECT: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1333
			int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1334
			int action_id = WP(w, menu_d).action_id;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1335
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1336
			/* We have a new entry at the top of the list of menu 9 when networking
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1337
			*  so keep that in count */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1338
			if (_networking && WP(w, menu_d).main_button == 9) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1339
				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1340
			} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1341
				index = GetPlayerIndexFromMenu(index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1342
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1343
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1344
			if (index < 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1345
				Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1346
				if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1347
					index = WP(w, menu_d).sel_index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1348
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1349
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1350
			DeleteWindow(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1351
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1352
			if (index >= 0) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1353
				assert(index >= 0 && index < 30);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1354
				_menu_clicked_procs[action_id](index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1355
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1356
		} break;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1357
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1358
		case WE_POPUPMENU_OVER: {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1359
			int index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1360
			UpdatePlayerMenuHeight(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1361
			index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1362
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1363
			/* We have a new entry at the top of the list of menu 9 when networking
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1364
			* so keep that in count */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1365
			if (_networking && WP(w, menu_d).main_button == 9) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1366
				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1367
			} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1368
				index = GetPlayerIndexFromMenu(index);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1369
			}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1370
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1371
			if (index == -1 || index == WP(w, menu_d).sel_index) return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1372
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1373
			WP(w, menu_d).sel_index = index;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1374
			SetWindowDirty(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1375
			return;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1376
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1377
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1378
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1379
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1380
static const Widget _player_menu_widgets[] = {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1381
{    WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL},
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1382
{ WIDGETS_END},
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1383
};
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1384
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1385
static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1386
{
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1387
	w->LowerWidget(main_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1388
	w->InvalidateWidget(main_button);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1389
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1390
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1391
	Point pos = GetToolbarDropdownPos(main_button, 241, 82);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1392
	w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1393
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1394
	WP(w, menu_d).item_count = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1395
	WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1396
	if (_networking && main_button == 9) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1397
		if (_local_player != PLAYER_SPECTATOR) {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1398
			WP(w, menu_d).sel_index++;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1399
		} else {
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1400
			/* Select client list by default for spectators */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1401
			WP(w, menu_d).sel_index = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1402
		}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1403
	}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1404
	WP(w, menu_d).action_id = main_button;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1405
	WP(w, menu_d).main_button = main_button;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1406
	WP(w, menu_d).checked_items = gray;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1407
	WP(w, menu_d).disabled_items = 0;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1408
	_popup_menu_active = true;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1409
	SndPlayFx(SND_15_BEEP);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1410
	return w;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1411
}
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1412
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1413
/* --- Allocating the toolbar --- */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1414
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
  1415
Window *AllocateToolbar()
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4013
diff changeset
  1416
{
10281
85a77bfe5614 (svn r12813) -Fix [FS#1943]: the 'last built railtype' got reset too often.
rubidium
parents: 10237
diff changeset
  1417
	/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
10235
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1418
	_last_built_roadtype = ROADTYPE_ROAD;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1419
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1420
	Window *w = AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1421
	if (w == NULL) return NULL;
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1422
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1423
	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1424
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1425
	w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1426
	w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1427
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1428
	/* 'w' is for sure a WC_MAIN_TOOLBAR */
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1429
	PositionMainToolbar(w);
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1430
684949ed0f03 (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 10229
diff changeset
  1431
	return w;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1432
}