src/toolbar_gui.cpp
author belugas
Sat, 14 Jun 2008 01:45:58 +0000
changeset 9518 bc938928f466
parent 9513 17d3f5505bf5
child 9519 e75bc0300488
permissions -rw-r--r--
(svn r13514) -Codechange: Removal of dead code (or useless, to be more exact)
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     1
/* $Id$ */
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     2
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     3
/** @file toolbar_gui.cpp Code related to the (main) toolbar. */
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     4
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     5
#include "stdafx.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     6
#include "openttd.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     7
#include "gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     8
#include "window_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
     9
#include "window_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    10
#include "viewport_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    11
#include "command_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    12
#include "variables.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    13
#include "train.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    14
#include "roadveh.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    15
#include "vehicle_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    16
#include "rail_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    17
#include "road_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    18
#include "date_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    19
#include "vehicle_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    20
#include "sound_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    21
#include "terraform_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    22
#include "transparency.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    23
#include "strings_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    24
#include "player_base.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    25
#include "player_func.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    26
#include "player_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    27
#include "settings_type.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    28
#include "toolbar_gui.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    29
#include "vehicle_base.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    30
#include "gfx_func.h"
8965
29a591456a2f (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 8726
diff changeset
    31
#include "cheat_func.h"
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    32
#include "transparency_gui.h"
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    33
#include "screenshot.h"
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    34
#include "newgrf_config.h"
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    35
#include "signs_func.h"
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    36
#include "fios.h"
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    37
#include "functions.h"
9336
6baad5b3033d (svn r13228) -Codechange: split console.h.
rubidium
parents: 9333
diff changeset
    38
#include "console_gui.h"
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8975
diff changeset
    39
#include "news_gui.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    40
#include "tilehighlight_func.h"
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    41
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    42
#include "network/network.h"
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    43
#include "network/network_gui.h"
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    44
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    45
#include "table/strings.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    46
#include "table/sprites.h"
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    47
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
    48
static void PopupMainToolbMenu(Window *parent, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask = 0, int sel_index = 0, int checked_items = 0);
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
    49
static void PopupMainPlayerToolbMenu(Window *parent, int main_button, int gray);
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    50
static void SplitToolbar(Window *w);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    51
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    52
RailType _last_built_railtype;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    53
RoadType _last_built_roadtype;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    54
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    55
enum ToolbarMode {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    56
	TB_NORMAL,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    57
	TB_UPPER,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    58
	TB_LOWER
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    59
};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    60
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    61
static ToolbarMode _toolbar_mode;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
    62
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    63
static void SelectSignTool()
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    64
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    65
	if (_cursor.sprite == SPR_CURSOR_SIGN) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    66
		ResetObjectToPlace();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    67
	} else {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    68
		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    69
		_place_proc = PlaceProc_Sign;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    70
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    71
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    72
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    73
/** Returns the position where the toolbar wants the menu to appear.
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    74
 * Make sure the dropdown is fully visible within the window.
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    75
 * x + w->left because x is supposed to be the offset of the toolbar-button
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    76
 * we clicked on and w->left the toolbar window itself. So meaning that
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    77
 * the default position is aligned with the left side of the clicked button */
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
    78
static Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    79
{
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8965
diff changeset
    80
	const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    81
	Point pos;
8726
0d8a2fdb5bbb (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 8723
diff changeset
    82
	pos.x = w->widget[GB(parent_button, 0, 8)].left;
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    83
	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
8726
0d8a2fdb5bbb (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 8723
diff changeset
    84
	pos.y = w->height;
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    85
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    86
	return pos;
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    87
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
    88
9144
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    89
/**
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
    90
 * Retrieve the menu item number from a position
9144
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    91
 * @param w Window holding the menu items
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    92
 * @param x X coordinate of the position
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    93
 * @param y Y coordinate of the position
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    94
 * @return Index number of the menu item, or \c -1 if no valid selection under position
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    95
 */
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
    96
static int GetMenuItemIndex(const Window *w, int item_count, int disabled_items)
9144
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
    97
{
9162
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
    98
	int x = _cursor.pos.x;
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
    99
	int y = _cursor.pos.y;
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
   100
9144
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   101
	if ((x -= w->left) >= 0 && x < w->width && (y -= w->top + 1) >= 0) {
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   102
		y /= 10;
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   103
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
   104
		if (y < item_count &&
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
   105
				!HasBit(disabled_items, y)) {
9144
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   106
			return y;
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   107
		}
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   108
	}
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   109
	return -1;
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   110
}
4c8d0193ebe0 (svn r13006) -Codechange: GetMenuItemIndex is only used for the toolbar, so move it to there.
rubidium
parents: 9142
diff changeset
   111
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   112
/* --- Pausing --- */
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   113
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   114
static void ToolbarPauseClick(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   115
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   116
	if (_networking && !_network_server) return; // only server can pause the game
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   117
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   118
	if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   119
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   120
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   121
/* --- Fast forwarding --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   122
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   123
static void ToolbarFastForwardClick(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   124
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   125
	_fast_forward ^= true;
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   126
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   127
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   128
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   129
/* --- Options button menu --- */
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   130
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   131
static void ToolbarOptionsClick(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   132
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   133
	uint16 x = 0;
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   134
	if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES))    SetBit(x,  6);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   135
	if (HasBit(_display_opt, DO_SHOW_STATION_NAMES)) SetBit(x,  7);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   136
	if (HasBit(_display_opt, DO_SHOW_SIGNS))         SetBit(x,  8);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   137
	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   138
	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   139
	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   140
	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   141
	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   142
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   143
	PopupMainToolbMenu(w, 2, STR_02C4_GAME_OPTIONS, 14, 0, 0, x);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   144
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   145
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   146
static void MenuClickSettings(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   147
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   148
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   149
		case 0: ShowGameOptions();      return;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   150
		case 1: ShowGameDifficulty();   return;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   151
		case 2: ShowPatchesSelection(); return;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   152
		case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig);   return;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   153
		case 4: ShowTransparencyToolbar(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   154
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   155
		case  6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES);    break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   156
		case  7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   157
		case  8: ToggleBit(_display_opt, DO_SHOW_SIGNS);         break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   158
		case  9: ToggleBit(_display_opt, DO_WAYPOINTS);          break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   159
		case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION);     break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   160
		case 11: ToggleBit(_display_opt, DO_FULL_DETAIL);        break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   161
		case 12: ToggleTransparency(TO_HOUSES);                  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   162
		case 13: ToggleTransparency(TO_SIGNS);                   break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   163
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   164
	MarkWholeScreenDirty();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   165
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   166
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   167
/* --- Saving/loading button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   168
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   169
static void ToolbarSaveClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   170
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   171
	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   172
}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   173
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   174
static void ToolbarScenSaveOrLoad(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   175
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   176
	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   177
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   178
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   179
static void MenuClickSaveLoad(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   180
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   181
	if (_game_mode == GM_EDITOR) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   182
		switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   183
			case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO);  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   184
			case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO);  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   185
			case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   186
			case 3: AskExitToGameMenu();                    break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   187
			case 5: HandleExitGameRequest();                break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   188
		}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   189
	} else {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   190
		switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   191
			case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   192
			case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   193
			case 2: AskExitToGameMenu();               break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   194
			case 3: HandleExitGameRequest();           break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   195
		}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   196
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   197
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   198
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   199
/* --- Map button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   200
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   201
static void ToolbarMapClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   202
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   203
	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   204
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   205
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   206
static void MenuClickMap(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   207
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   208
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   209
		case 0: ShowSmallMap();            break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   210
		case 1: ShowExtraViewPortWindow(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   211
		case 2: ShowSignList();            break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   212
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   213
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   214
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   215
static void MenuClickScenMap(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   216
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   217
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   218
		case 0: ShowSmallMap();            break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   219
		case 1: ShowExtraViewPortWindow(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   220
		case 2: ShowSignList();            break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   221
		case 3: ShowTownDirectory();       break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   222
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   223
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   224
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   225
/* --- Town button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   226
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   227
static void ToolbarTownClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   228
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   229
	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   230
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   231
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   232
static void MenuClickTown(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   233
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   234
	ShowTownDirectory();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   235
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   236
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   237
/* --- Subidies button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   238
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   239
static void ToolbarSubsidiesClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   240
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   241
	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   242
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   243
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   244
static void MenuClickSubsidies(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   245
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   246
	ShowSubsidiesList();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   247
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   248
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   249
/* --- Stations button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   250
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   251
static void ToolbarStationsClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   252
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   253
	PopupMainPlayerToolbMenu(w, 7, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   254
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   255
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   256
static void MenuClickStations(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   257
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   258
	ShowPlayerStations((PlayerID)index);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   259
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   260
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   261
/* --- Finances button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   262
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   263
static void ToolbarFinancesClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   264
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   265
	PopupMainPlayerToolbMenu(w, 8, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   266
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   267
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   268
static void MenuClickFinances(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   269
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   270
	ShowPlayerFinances((PlayerID)index);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   271
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   272
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   273
/* --- Company's button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   274
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   275
static void ToolbarPlayersClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   276
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   277
	PopupMainPlayerToolbMenu(w, 9, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   278
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   279
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   280
static void MenuClickCompany(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   281
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   282
	if (_networking && index == 0) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   283
		ShowClientList();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   284
	} else {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   285
		if (_networking) index--;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   286
		ShowPlayerCompany((PlayerID)index);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   287
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   288
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   289
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   290
/* --- Graphs button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   291
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   292
static void ToolbarGraphsClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   293
{
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   294
	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   295
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   296
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   297
static void MenuClickGraphs(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   298
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   299
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   300
		case 0: ShowOperatingProfitGraph();    break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   301
		case 1: ShowIncomeGraph();             break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   302
		case 2: ShowDeliveredCargoGraph();     break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   303
		case 3: ShowPerformanceHistoryGraph(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   304
		case 4: ShowCompanyValueGraph();       break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   305
		case 5: ShowCargoPaymentRates();       break;
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   306
		/* functions for combined graphs/league button */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   307
		case 6: ShowCompanyLeagueTable();      break;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   308
		case 7: ShowPerformanceRatingDetail(); break;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   309
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   310
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   311
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   312
/* --- League button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   313
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   314
static void ToolbarLeagueClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   315
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   316
	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   317
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   318
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   319
static void MenuClickLeague(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   320
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   321
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   322
		case 0: ShowCompanyLeagueTable();      break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   323
		case 1: ShowPerformanceRatingDetail(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   324
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   325
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   326
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   327
/* --- Industries button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   328
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   329
static void ToolbarIndustryClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   330
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   331
	/* Disable build-industry menu if we are a spectator */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   332
	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   333
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   334
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   335
static void MenuClickIndustry(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   336
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   337
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   338
		case 0: ShowIndustryDirectory();   break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   339
		case 1: ShowBuildIndustryWindow(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   340
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   341
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   342
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   343
/* --- Trains button menu + 1 helper function for all vehicles. --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   344
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   345
static void ToolbarVehicleClick(Window *w, VehicleType veh)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   346
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   347
	const Vehicle *v;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   348
	int dis = ~0;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   349
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   350
	FOR_ALL_VEHICLES(v) {
9053
dbda5b38bcac (svn r12892) -Fix: too many items in the vehicle toolbars were greyed out.
rubidium
parents: 9014
diff changeset
   351
		if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   352
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   353
	PopupMainPlayerToolbMenu(w, 13 + veh, dis);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   354
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   355
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   356
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   357
static void ToolbarTrainClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   358
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   359
	ToolbarVehicleClick(w, VEH_TRAIN);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   360
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   361
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   362
static void MenuClickShowTrains(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   363
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   364
	ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   365
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   366
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   367
/* --- Road vehicle button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   368
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   369
static void ToolbarRoadClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   370
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   371
	ToolbarVehicleClick(w, VEH_ROAD);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   372
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   373
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   374
static void MenuClickShowRoad(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   375
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   376
	ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   377
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   378
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   379
/* --- Ship button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   380
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   381
static void ToolbarShipClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   382
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   383
	ToolbarVehicleClick(w, VEH_SHIP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   384
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   385
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   386
static void MenuClickShowShips(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   387
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   388
	ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   389
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   390
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   391
/* --- Aircraft button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   392
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   393
static void ToolbarAirClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   394
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   395
	ToolbarVehicleClick(w, VEH_AIRCRAFT);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   396
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   397
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   398
static void MenuClickShowAir(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   399
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   400
	ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   401
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   402
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   403
/* --- Zoom in button --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   404
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   405
static void ToolbarZoomInClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   406
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   407
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   408
		w->HandleButtonClick(17);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   409
		SndPlayFx(SND_15_BEEP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   410
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   411
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   412
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   413
/* --- Zoom out button --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   414
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   415
static void ToolbarZoomOutClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   416
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   417
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   418
		w->HandleButtonClick(18);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   419
		SndPlayFx(SND_15_BEEP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   420
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   421
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   422
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   423
/* --- Rail button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   424
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   425
static void ToolbarBuildRailClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   426
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   427
	const Player *p = GetPlayer(_local_player);
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   428
	PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes, _last_built_railtype);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   429
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   430
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   431
static void MenuClickBuildRail(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   432
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   433
	_last_built_railtype = (RailType)index;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   434
	ShowBuildRailToolbar(_last_built_railtype, -1);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   435
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   436
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   437
/* --- Road button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   438
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   439
static void ToolbarBuildRoadClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   440
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   441
	const Player *p = GetPlayer(_local_player);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   442
	/* The standard road button is *always* available */
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   443
	PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD), _last_built_roadtype);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   444
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   445
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   446
static void MenuClickBuildRoad(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   447
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   448
	_last_built_roadtype = (RoadType)index;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   449
	ShowBuildRoadToolbar(_last_built_roadtype);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   450
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   451
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   452
/* --- Water button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   453
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   454
static void ToolbarBuildWaterClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   455
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   456
	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   457
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   458
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   459
static void MenuClickBuildWater(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   460
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   461
	ShowBuildDocksToolbar();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   462
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   463
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   464
/* --- Airport button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   465
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   466
static void ToolbarBuildAirClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   467
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   468
	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   469
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   470
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   471
static void MenuClickBuildAir(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   472
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   473
	ShowBuildAirToolbar();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   474
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   475
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   476
/* --- Forest button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   477
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   478
static void ToolbarForestClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   479
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   480
	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   481
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   482
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   483
static void MenuClickForest(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   484
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   485
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   486
		case 0: ShowTerraformToolbar();  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   487
		case 1: ShowBuildTreesToolbar(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   488
		case 2: SelectSignTool();        break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   489
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   490
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   491
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   492
/* --- Music button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   493
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   494
static void ToolbarMusicClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   495
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   496
	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   497
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   498
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   499
static void MenuClickMusicWindow(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   500
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   501
	ShowMusicWindow();
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   502
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   503
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   504
/* --- Newspaper button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   505
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   506
static void ToolbarNewspaperClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   507
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   508
	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   509
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   510
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   511
static void MenuClickNewspaper(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   512
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   513
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   514
		case 0: ShowLastNewsMessage(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   515
		case 1: ShowMessageOptions();  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   516
		case 2: ShowMessageHistory();  break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   517
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   518
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   519
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   520
/* --- Help button menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   521
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   522
static void ToolbarHelpClick(Window *w)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   523
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   524
	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   525
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   526
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   527
static void MenuClickSmallScreenshot()
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   528
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   529
	SetScreenshotType(SC_VIEWPORT);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   530
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   531
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   532
static void MenuClickWorldScreenshot()
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   533
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   534
	SetScreenshotType(SC_WORLD);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   535
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   536
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   537
static void MenuClickHelp(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   538
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   539
	switch (index) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   540
		case 0: PlaceLandBlockInfo();       break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   541
		case 2: IConsoleSwitch();           break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   542
		case 3: MenuClickSmallScreenshot(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   543
		case 4: MenuClickWorldScreenshot(); break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   544
		case 5: ShowAboutWindow();          break;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   545
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   546
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   547
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   548
/* --- Switch toolbar button --- */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   549
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   550
static void ToolbarSwitchClick(Window *w)
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   551
{
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   552
	if (_toolbar_mode != TB_LOWER) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   553
		_toolbar_mode = TB_LOWER;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   554
	} else {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   555
		_toolbar_mode = TB_UPPER;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   556
	}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   557
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   558
	SplitToolbar(w);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   559
	w->HandleButtonClick(27);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   560
	SetWindowDirty(w);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   561
	SndPlayFx(SND_15_BEEP);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   562
}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   563
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   564
/* --- Scenario editor specific handlers. */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   565
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   566
static void ToolbarScenDateBackward(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   567
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   568
	/* don't allow too fast scrolling */
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   569
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   570
		w->HandleButtonClick(6);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   571
		w->SetDirty();
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   572
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9336
diff changeset
   573
		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9336
diff changeset
   574
		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   575
	}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   576
	_left_button_clicked = false;
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   577
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   578
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   579
static void ToolbarScenDateForward(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   580
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   581
	/* don't allow too fast scrolling */
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   582
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   583
		w->HandleButtonClick(7);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   584
		w->SetDirty();
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   585
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9336
diff changeset
   586
		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9336
diff changeset
   587
		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   588
	}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   589
	_left_button_clicked = false;
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   590
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   591
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   592
static void ToolbarScenMapTownDir(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   593
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   594
	/* Scenario editor button, *hack*hack* use different button to activate */
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
   595
	PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   596
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   597
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   598
static void ToolbarScenZoomIn(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   599
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   600
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   601
		w->HandleButtonClick(9);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   602
		SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   603
	}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   604
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   605
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   606
static void ToolbarScenZoomOut(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   607
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   608
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   609
		w->HandleButtonClick(10);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   610
		SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   611
	}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   612
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   613
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   614
static void ToolbarScenGenLand(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   615
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   616
	w->HandleButtonClick(11);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   617
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   618
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   619
	ShowEditorTerraformToolbar();
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   620
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   621
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   622
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   623
static void ToolbarScenGenTown(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   624
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   625
	w->HandleButtonClick(12);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   626
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   627
	ShowBuildTownWindow();
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   628
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   629
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   630
static void ToolbarScenGenIndustry(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   631
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   632
	w->HandleButtonClick(13);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   633
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   634
	ShowBuildIndustryWindow();
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   635
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   636
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   637
static void ToolbarScenBuildRoad(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   638
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   639
	w->HandleButtonClick(14);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   640
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   641
	ShowBuildRoadScenToolbar();
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   642
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   643
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   644
static void ToolbarScenPlantTrees(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   645
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   646
	w->HandleButtonClick(15);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   647
	SndPlayFx(SND_15_BEEP);
9195
738780fcebc8 (svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents: 9165
diff changeset
   648
	ShowBuildTreesToolbar();
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   649
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   650
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   651
static void ToolbarScenPlaceSign(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   652
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   653
	w->HandleButtonClick(16);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   654
	SndPlayFx(SND_15_BEEP);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   655
	SelectSignTool();
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   656
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   657
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   658
static void ToolbarBtn_NULL(Window *w)
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   659
{
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   660
}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   661
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   662
/* --- Resizing the toolbar */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   663
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   664
static void ResizeToolbar(Window *w)
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   665
{
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   666
	/* There are 27 buttons plus some spacings if the space allows it */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   667
	uint button_width;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   668
	uint spacing;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   669
	if (w->width >= 27 * 22) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   670
		button_width = 22;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   671
		spacing = w->width - (27 * button_width);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   672
	} else {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   673
		button_width = w->width / 27;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   674
		spacing = 0;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   675
	}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   676
	uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   677
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   678
	for (uint i = 0, x = 0, j = 0; i < 27; i++) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   679
		if (extra_spacing_at[j] == i) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   680
			j++;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   681
			uint add = spacing / (lengthof(extra_spacing_at) - j);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   682
			spacing -= add;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   683
			x += add;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   684
		}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   685
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   686
		w->widget[i].type = WWT_IMGBTN;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   687
		w->widget[i].left = x;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   688
		x += (spacing != 0) ? button_width : (w->width - x) / (27 - i);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   689
		w->widget[i].right = x - 1;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   690
	}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   691
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   692
	w->widget[27].type = WWT_EMPTY;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   693
	_toolbar_mode = TB_NORMAL;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   694
}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   695
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   696
/* --- Split the toolbar */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   697
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   698
static void SplitToolbar(Window *w)
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   699
{
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   700
	static const byte arrange14[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   701
		0,  1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   702
		2,  3,  4,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   703
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   704
	static const byte arrange15[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   705
		0,  1,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   706
		0,  2,  4,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   707
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   708
	static const byte arrange16[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   709
		0,  1,  2,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   710
		0,  1,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   711
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   712
	static const byte arrange17[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   713
		0,  1,  2,  4,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   714
		0,  1,  3,  4,  6,  5,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   715
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   716
	static const byte arrange18[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   717
		0,  1,  2,  4,  5,  6,  7,  8,  9, 12, 19, 20, 21, 22, 23, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   718
		0,  1,  3,  4,  5,  6,  7, 10, 13, 14, 15, 16, 24, 25, 26, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   719
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   720
	static const byte arrange19[] = {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   721
		0,  1,  2,  4,  5,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   722
		0,  1,  3,  4,  7,  8,  9, 10, 12, 25, 19, 20, 21, 22, 23, 26, 17, 18, 27,
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   723
	};
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   724
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   725
	static const byte *arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 };
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   726
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   727
	static const uint icon_size = 22;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   728
	uint max_icons = max(14U, (w->width + icon_size / 2) / icon_size);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   729
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   730
	assert(max_icons >= 14 && max_icons <= 19);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   731
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   732
	/* first hide all icons */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   733
	for (uint i = 0; i < 27; i++) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   734
		w->widget[i].type = WWT_EMPTY;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   735
	}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   736
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   737
	/* now activate them all on their proper positions */
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   738
	for (uint i = 0, x = 0, n = max_icons - 14; i < max_icons; i++) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   739
		uint icon = arrangements[n][i + ((_toolbar_mode == TB_LOWER) ? max_icons : 0)];
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   740
		w->widget[icon].type = WWT_IMGBTN;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   741
		w->widget[icon].left = x;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   742
		x += (w->width - x) / (max_icons - i);
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   743
		w->widget[icon].right = x - 1;
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   744
	}
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   745
}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   746
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   747
/* --- Toolbar handling for the 'normal' case */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   748
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   749
typedef void ToolbarButtonProc(Window *w);
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   750
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   751
static ToolbarButtonProc * const _toolbar_button_procs[] = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   752
	ToolbarPauseClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   753
	ToolbarFastForwardClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   754
	ToolbarOptionsClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   755
	ToolbarSaveClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   756
	ToolbarMapClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   757
	ToolbarTownClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   758
	ToolbarSubsidiesClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   759
	ToolbarStationsClick,
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   760
	ToolbarFinancesClick,
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   761
	ToolbarPlayersClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   762
	ToolbarGraphsClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   763
	ToolbarLeagueClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   764
	ToolbarIndustryClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   765
	ToolbarTrainClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   766
	ToolbarRoadClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   767
	ToolbarShipClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   768
	ToolbarAirClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   769
	ToolbarZoomInClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   770
	ToolbarZoomOutClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   771
	ToolbarBuildRailClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   772
	ToolbarBuildRoadClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   773
	ToolbarBuildWaterClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   774
	ToolbarBuildAirClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   775
	ToolbarForestClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   776
	ToolbarMusicClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   777
	ToolbarNewspaperClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   778
	ToolbarHelpClick,
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   779
	ToolbarSwitchClick,
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   780
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   781
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   782
struct MainToolbarWindow : Window {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   783
	MainToolbarWindow(const WindowDesc *desc) : Window(desc)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   784
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   785
		this->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   786
		this->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   787
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   788
		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   789
9310
d2f150a6e2f0 (svn r13178) -Fix (r13173): the main toolbar didn't respect patch settings, it was always positioned on the right side
smatz
parents: 9305
diff changeset
   790
		this->FindWindowPlacementAndResize(desc);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   791
		PositionMainToolbar(this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   792
		DoZoomInOutWindow(ZOOM_NONE, this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   793
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   794
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   795
	virtual void OnPaint()
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   796
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   797
		/* Draw brown-red toolbar bg. */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   798
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   799
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   800
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   801
		/* If spectator, disable all construction buttons
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   802
		* ie : Build road, rail, ships, airports and landscaping
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   803
		* Since enabled state is the default, just disable when needed */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   804
		this->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   805
		/* disable company list drop downs, if there are no companies */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   806
		this->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   807
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   808
		this->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   809
		this->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   810
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   811
		this->DrawWidgets();
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   812
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   813
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   814
	virtual void OnClick(Point pt, int widget)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   815
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   816
		if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   817
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   818
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   819
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   820
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   821
		switch (keycode) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   822
			case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   823
			case WKC_F2: ShowGameOptions(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   824
			case WKC_F3: MenuClickSaveLoad(0); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   825
			case WKC_F4: ShowSmallMap(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   826
			case WKC_F5: ShowTownDirectory(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   827
			case WKC_F6: ShowSubsidiesList(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   828
			case WKC_F7: ShowPlayerStations(_local_player); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   829
			case WKC_F8: ShowPlayerFinances(_local_player); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   830
			case WKC_F9: ShowPlayerCompany(_local_player); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   831
			case WKC_F10: ShowOperatingProfitGraph(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   832
			case WKC_F11: ShowCompanyLeagueTable(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   833
			case WKC_F12: ShowBuildIndustryWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   834
			case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_TRAIN); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   835
			case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_ROAD); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   836
			case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_SHIP); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   837
			case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_AIRCRAFT); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   838
			case WKC_NUM_PLUS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   839
			case WKC_EQUALS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   840
			case WKC_SHIFT | WKC_EQUALS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   841
			case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   842
			case WKC_NUM_MINUS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   843
			case WKC_MINUS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   844
			case WKC_SHIFT | WKC_MINUS: // Fall through
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   845
			case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   846
			case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   847
			case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   848
			case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   849
			case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   850
			case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   851
			case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   852
			case WKC_CTRL  | 'S': MenuClickSmallScreenshot(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   853
			case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   854
			case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   855
			case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   856
			case 'L': ShowTerraformToolbar(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   857
			case 'M': ShowSmallMap(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   858
			case 'V': ShowExtraViewPortWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   859
			default: return ES_NOT_HANDLED;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   860
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   861
		return ES_HANDLED;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   862
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   863
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   864
	virtual void OnPlaceObject(Point pt, TileIndex tile)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   865
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   866
		_place_proc(tile);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   867
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   868
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   869
	virtual void OnTick()
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   870
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   871
		if (this->IsWidgetLowered(0) != !!_pause_game) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   872
			this->ToggleWidgetLoweredState(0);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   873
			this->InvalidateWidget(0);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   874
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   875
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   876
		if (this->IsWidgetLowered(1) != !!_fast_forward) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   877
			this->ToggleWidgetLoweredState(1);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   878
			this->InvalidateWidget(1);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   879
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   880
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   881
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   882
	virtual void OnResize(Point new_size, Point delta)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   883
	{
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   884
		if (this->width <= 19 * 22) {
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   885
			SplitToolbar(this);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   886
		} else {
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   887
			ResizeToolbar(this);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   888
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   889
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   890
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   891
	virtual void OnTimeout()
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   892
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   893
		for (uint i = 2; i < this->widget_count; i++) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   894
			if (this->IsWidgetLowered(i)) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   895
				this->RaiseWidget(i);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   896
				this->InvalidateWidget(i);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   897
			}
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   898
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   899
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   900
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   901
	virtual void OnInvalidateData(int data)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   902
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   903
		if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   904
	}
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   905
};
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   906
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   907
static const Widget _toolb_normal_widgets[] = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   908
{     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   909
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   910
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   911
{   WWT_IMGBTN_2,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   912
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   913
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   914
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   915
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   916
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   917
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   918
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   919
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   920
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   921
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   922
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   923
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   924
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   925
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   926
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   927
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   928
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   929
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   930
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   931
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   932
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   933
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   934
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   935
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   936
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_LANDSCAPING,     STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   937
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   938
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   939
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   940
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_QUERY,           STR_0186_LAND_BLOCK_INFORMATION},
9425
fe15794c1448 (svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
rubidium
parents: 9354
diff changeset
   941
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_SWITCH_TOOLBAR,      STR_EMPTY}, // switch toolbar button. only active when toolbar has been split
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   942
{   WIDGETS_END},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   943
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   944
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   945
static const WindowDesc _toolb_normal_desc = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   946
	0, 0, 0, 22, 640, 22,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   947
	WC_MAIN_TOOLBAR, WC_NONE,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   948
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   949
	_toolb_normal_widgets,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   950
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   951
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   952
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   953
/* --- Toolbar handling for the scenario editor */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
   954
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   955
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   956
	ToolbarPauseClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   957
	ToolbarFastForwardClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   958
	ToolbarOptionsClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   959
	ToolbarScenSaveOrLoad,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   960
	ToolbarBtn_NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   961
	ToolbarBtn_NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   962
	ToolbarScenDateBackward,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   963
	ToolbarScenDateForward,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   964
	ToolbarScenMapTownDir,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   965
	ToolbarScenZoomIn,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   966
	ToolbarScenZoomOut,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   967
	ToolbarScenGenLand,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   968
	ToolbarScenGenTown,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   969
	ToolbarScenGenIndustry,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   970
	ToolbarScenBuildRoad,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   971
	ToolbarScenPlantTrees,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   972
	ToolbarScenPlaceSign,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   973
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   974
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   975
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   976
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   977
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   978
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   979
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   980
	ToolbarMusicClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   981
	NULL,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   982
	ToolbarHelpClick,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   983
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
   984
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   985
struct ScenarioEditorToolbarWindow : Window {
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   986
private:
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   987
	enum ToolbarScenEditorWidgets {
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   988
		TBSE_PAUSE        = 0,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   989
		TBSE_FASTFORWARD,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   990
		TBSE_SPACERPANEL  = 4,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   991
		TBSE_DATEBACKWARD = 6,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   992
		TBSE_DATEFORWARD,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   993
		TBSE_ZOOMIN       = 9,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   994
		TBSE_ZOOMOUT,
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   995
	};
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   996
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
   997
public:
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   998
	ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
   999
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1000
		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1001
9311
96b830227d9e (svn r13179) -Fix (r13173): r13178 applies to the main toolbar in Scenario Editor, too
smatz
parents: 9310
diff changeset
  1002
		this->FindWindowPlacementAndResize(desc);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1003
		PositionMainToolbar(this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1004
		DoZoomInOutWindow(ZOOM_NONE, this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1005
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1006
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1007
	virtual void OnPaint()
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1008
	{
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1009
		this->SetWidgetDisabledState(TBSE_DATEBACKWARD, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1010
		this->SetWidgetDisabledState(TBSE_DATEFORWARD, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1011
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1012
		/* Draw brown-red toolbar bg. */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1013
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1014
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1015
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1016
		this->DrawWidgets();
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1017
9354
845e07db4549 (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents: 9336
diff changeset
  1018
		SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1019
		DrawStringCenteredTruncated(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1020
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1021
		/* We hide this panel when the toolbar space gets too small */
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1022
		const Widget *panel = &this->widget[TBSE_SPACERPANEL];
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1023
		if (panel->left != panel->right) {
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1024
			DrawStringCenteredTruncated(panel->left + 1, panel->right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1025
			DrawStringCenteredTruncated(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1026
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1027
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1028
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1029
	virtual void OnClick(Point pt, int widget)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1030
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1031
		if (_game_mode == GM_MENU) return;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1032
		_scen_toolbar_button_procs[widget](this);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1033
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1034
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1035
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1036
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1037
		switch (keycode) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1038
			case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1039
			case WKC_F2: ShowGameOptions(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1040
			case WKC_F3: MenuClickSaveLoad(0); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1041
			case WKC_F4: ToolbarScenGenLand(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1042
			case WKC_F5: ToolbarScenGenTown(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1043
			case WKC_F6: ToolbarScenGenIndustry(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1044
			case WKC_F7: ToolbarScenBuildRoad(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1045
			case WKC_F8: ToolbarScenPlantTrees(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1046
			case WKC_F9: ToolbarScenPlaceSign(this); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1047
			case WKC_F10: ShowMusicWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1048
			case WKC_F11: PlaceLandBlockInfo(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1049
			case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1050
			case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1051
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1052
			/* those following are all fall through */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1053
			case WKC_NUM_PLUS:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1054
			case WKC_EQUALS:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1055
			case WKC_SHIFT | WKC_EQUALS:
9512
bc878acad6ab (svn r13503) -Fix(r13173)[FS#2073]: Wrong widget numbers & event handlers were assigned to the zoom in and out buttons in the scenario editor
belugas
parents: 9425
diff changeset
  1056
			case WKC_SHIFT | WKC_F5: ToolbarScenZoomIn(this); break;
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1057
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1058
			/* those following are all fall through */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1059
			case WKC_NUM_MINUS:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1060
			case WKC_MINUS:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1061
			case WKC_SHIFT | WKC_MINUS:
9512
bc878acad6ab (svn r13503) -Fix(r13173)[FS#2073]: Wrong widget numbers & event handlers were assigned to the zoom in and out buttons in the scenario editor
belugas
parents: 9425
diff changeset
  1062
			case WKC_SHIFT | WKC_F6: ToolbarScenZoomOut(this); break;
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1063
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1064
			case 'L': ShowEditorTerraformToolbar(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1065
			case 'M': ShowSmallMap(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1066
			case 'V': ShowExtraViewPortWindow(); break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1067
			default: return ES_NOT_HANDLED;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1068
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1069
		return ES_HANDLED;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1070
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1071
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1072
	virtual void OnPlaceObject(Point pt, TileIndex tile)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1073
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1074
		_place_proc(tile);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1075
	}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1076
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1077
	virtual void OnResize(Point new_size, Point delta)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1078
	{
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1079
		/* There are 15 buttons plus some spacings if the space allows it.
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1080
		 * Furthermore there are two panels of which one is non - essential
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1081
		 * and that one can be removed is the space is too small. */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1082
		uint buttons_width;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1083
		uint spacing;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1084
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1085
		static int normal_min_width = (15 * 22) + (2 * 130);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1086
		static int one_less_panel_min_width = (15 * 22) + 130;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1087
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1088
		if (this->width >= one_less_panel_min_width) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1089
			buttons_width = 15 * 22;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1090
			spacing = this->width - ((this->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1091
		} else {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1092
			buttons_width = this->width - 130;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1093
			spacing = 0;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1094
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1095
		uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 16, 0 };
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1096
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1097
		/* Yes, it defines about 27 widgets for this toolbar */
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1098
		for (uint i = 0, x = 0, j = 0, b = 0; i < 27; i++) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1099
			switch (i) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1100
				case 4:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1101
					this->widget[i].left = x;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1102
					if (this->width < normal_min_width) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1103
						this->widget[i].right = x;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1104
						j++;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1105
						continue;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1106
					}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1107
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1108
					x += 130;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1109
					this->widget[i].right = x - 1;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1110
					break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1111
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1112
				case 5: {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1113
					int offset = x - this->widget[i].left;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1114
					this->widget[i + 1].left  += offset;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1115
					this->widget[i + 1].right += offset;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1116
					this->widget[i + 2].left  += offset;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1117
					this->widget[i + 2].right += offset;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1118
					this->widget[i].left = x;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1119
					x += 130;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1120
					this->widget[i].right = x - 1;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1121
					i += 2;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1122
				} break;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1123
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1124
				default:
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1125
					if (this->widget[i].bottom == 0) continue;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1126
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1127
					this->widget[i].left = x;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1128
					x += buttons_width / (15 - b);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1129
					this->widget[i].right = x - 1;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1130
					buttons_width -= buttons_width / (15 - b);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1131
					b++;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1132
					break;
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1133
			}
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1134
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1135
			if (extra_spacing_at[j] == i) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1136
				j++;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1137
				uint add = spacing / (lengthof(extra_spacing_at) - j);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1138
				spacing -= add;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1139
				x += add;
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1140
			}
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1141
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1142
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1143
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1144
	virtual void OnTick()
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1145
	{
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1146
		if (this->IsWidgetLowered(TBSE_PAUSE) != !!_pause_game) {
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1147
			this->ToggleWidgetLoweredState(TBSE_PAUSE);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1148
			this->SetDirty();
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1149
		}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1150
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1151
		if (this->IsWidgetLowered(TBSE_FASTFORWARD) != !!_fast_forward) {
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1152
			this->ToggleWidgetLoweredState(TBSE_FASTFORWARD);
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1153
			this->SetDirty();
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1154
		}
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1155
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1156
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1157
	virtual void OnInvalidateData(int data)
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1158
	{
9513
17d3f5505bf5 (svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
belugas
parents: 9512
diff changeset
  1159
		if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT);
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1160
	}
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1161
};
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1162
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1163
static const Widget _toolb_scen_widgets[] = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1164
{  WWT_IMGBTN, RESIZE_LEFT, 14,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1165
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1166
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1167
{WWT_IMGBTN_2, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1168
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1169
{   WWT_PANEL, RESIZE_NONE, 14,   0,   0,  0, 21, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1170
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1171
{   WWT_PANEL, RESIZE_NONE, 14,   0, 129,  0, 21, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1172
{  WWT_IMGBTN, RESIZE_NONE, 14,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1173
{  WWT_IMGBTN, RESIZE_NONE, 14, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1174
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1175
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1176
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1177
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1178
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1179
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1180
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1181
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1182
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1183
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1184
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1185
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1186
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1187
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1188
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1189
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1190
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1191
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1192
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1193
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1194
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1195
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1196
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_QUERY,       STR_0186_LAND_BLOCK_INFORMATION},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1197
{WIDGETS_END},
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1198
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1199
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1200
static const WindowDesc _toolb_scen_desc = {
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1201
	0, 0, 130, 22, 640, 22,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1202
	WC_MAIN_TOOLBAR, WC_NONE,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1203
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1204
	_toolb_scen_widgets,
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1205
};
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1206
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1207
/* --- Rendering/handling the drop down menus --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1208
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1209
typedef void MenuClickedProc(int index);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1210
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1211
static MenuClickedProc * const _menu_clicked_procs[] = {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1212
	NULL,                 /* 0 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1213
	NULL,                 /* 1 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1214
	MenuClickSettings,    /* 2 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1215
	MenuClickSaveLoad,    /* 3 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1216
	MenuClickMap,         /* 4 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1217
	MenuClickTown,        /* 5 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1218
	MenuClickSubsidies,   /* 6 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1219
	MenuClickStations,    /* 7 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1220
	MenuClickFinances,    /* 8 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1221
	MenuClickCompany,     /* 9 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1222
	MenuClickGraphs,      /* 10 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1223
	MenuClickLeague,      /* 11 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1224
	MenuClickIndustry,    /* 12 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1225
	MenuClickShowTrains,  /* 13 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1226
	MenuClickShowRoad,    /* 14 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1227
	MenuClickShowShips,   /* 15 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1228
	MenuClickShowAir,     /* 16 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1229
	MenuClickScenMap,     /* 17 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1230
	NULL,                 /* 18 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1231
	MenuClickBuildRail,   /* 19 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1232
	MenuClickBuildRoad,   /* 20 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1233
	MenuClickBuildWater,  /* 21 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1234
	MenuClickBuildAir,    /* 22 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1235
	MenuClickForest,      /* 23 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1236
	MenuClickMusicWindow, /* 24 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1237
	MenuClickNewspaper,   /* 25 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1238
	MenuClickHelp,        /* 26 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1239
};
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1240
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1241
struct ToolbarMenuWindow : Window {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1242
	int item_count;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1243
	int sel_index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1244
	int main_button;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1245
	int action_id;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1246
	int checked_items;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1247
	int disabled_items;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1248
	StringID base_string;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1249
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1250
	ToolbarMenuWindow(int x, int y, int width, int height, const Widget *widgets, int item_count,
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1251
										int sel_index, int parent_button, StringID base_string, int checked_items,
9324
1320fbd5b84f (svn r13208) -Fix (r13173): it was possible to open invalid submenu from dropdowns
smatz
parents: 9317
diff changeset
  1252
										int disabled_items) :
9301
3b20dfb6c4e8 (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium
parents: 9273
diff changeset
  1253
			Window(x, y, width, height, WC_TOOLBAR_MENU, widgets),
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1254
			item_count(item_count), sel_index(sel_index), main_button(GB(parent_button, 0, 8)),
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1255
			action_id((GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button),
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1256
			checked_items(checked_items), disabled_items(disabled_items), base_string(base_string)
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1257
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1258
		this->widget[0].bottom = item_count * 10 + 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1259
		this->widget[0].right = this->width - 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1260
		this->flags4 &= ~WF_WHITE_BORDER_MASK;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1261
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1262
		this->FindWindowPlacementAndResize(width, height);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1263
	}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1264
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1265
	~ToolbarMenuWindow()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1266
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1267
		Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1268
		w->RaiseWidget(this->main_button);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1269
		w->SetDirty();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1270
	}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1271
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1272
	virtual void OnPaint()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1273
	{
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9242
diff changeset
  1274
		this->DrawWidgets();
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1275
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1276
		for (int i = 0, x = 1, y = 1; i != this->item_count; i++, y += 10) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1277
			TextColour color = HasBit(this->disabled_items, i) ? TC_GREY : (this->sel_index == i) ? TC_WHITE : TC_BLACK;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1278
			if (this->sel_index == i) GfxFillRect(x, y, x + this->width - 3, y + 9, 0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1279
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1280
			if (HasBit(this->checked_items, i)) DrawString(x + 2, y, STR_CHECKMARK, color);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1281
			DrawString(x + 2, y, this->base_string + i, color);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1282
		}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1283
	}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1284
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1285
	virtual void OnMouseLoop()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1286
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1287
		int index = GetMenuItemIndex(this, this->item_count, this->disabled_items);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1288
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1289
		if (_left_button_down) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1290
			if (index == -1 || index == this->sel_index) return;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1291
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1292
			this->sel_index = index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1293
			this->SetDirty();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1294
		} else {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1295
			if (index < 0) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1296
				Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1297
				if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) == this->main_button) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1298
					index = this->sel_index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1299
				}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1300
			}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1301
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1302
			int action_id = this->action_id;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1303
			delete this;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1304
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1305
			if (index >= 0) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1306
				assert((uint)index <= lengthof(_menu_clicked_procs));
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1307
				_menu_clicked_procs[action_id](index);
9162
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
  1308
			}
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1309
		}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1310
	}
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1311
};
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1312
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1313
/* Dynamic widget length determined by toolbar-string length.
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1314
 * See PopupMainToolbMenu en MenuWndProc */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1315
static const Widget _menu_widgets[] = {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1316
{    WWT_PANEL, RESIZE_NONE, 14, 0,  0, 0, 0, 0x0, STR_NULL},
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1317
{ WIDGETS_END},
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1318
};
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1319
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1320
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1321
/**
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1322
 * Get the maximum length of a given string in a string-list. This is an
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1323
 * implicit string-list where the ID's are consecutive
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1324
 * @param base_string StringID of the first string in the list
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1325
 * @param count amount of StringID's in the list
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1326
 * @return the length of the longest string
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1327
 */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1328
static int GetStringListMaxWidth(StringID base_string, byte count)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1329
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1330
	char buffer[512];
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1331
	int width, max_width = 0;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1332
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1333
	for (byte i = 0; i != count; i++) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1334
		GetString(buffer, base_string + i, lastof(buffer));
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1335
		width = GetStringBoundingBox(buffer).width;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1336
		if (width > max_width) max_width = width;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1337
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1338
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1339
	return max_width;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1340
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1341
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1342
/**
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1343
 * Show a general dropdown menu. The positioning of the dropdown menu
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1344
 * defaults to the left side of the parent_button, eg the button that caused
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1345
 * this window to appear. The only exceptions are when the right side of this
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1346
 * dropdown would fall outside the main toolbar window, in that case it is
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1347
 * aligned with the toolbar's right side.
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1348
 * Since the disable-mask is only 8 bits right now, these dropdowns are
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1349
 * restricted to 8 items max if any bits of disabled_mask are active.
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1350
 * @param parent Pointer to a window this dropdown menu belongs to. Has no effect
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1351
 * whatsoever, only graphically for positioning.
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1352
 * @param parent_button The widget identifier of the button that was clicked for
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1353
 * this dropdown. The created dropdown then knows what button to raise (button) on
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1354
 * action and whose function to execute (action).
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1355
 * It is possible to appoint another button for an action event by setting the
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1356
 * upper 8 bits of this parameter. If non is set, action is presumed to be the same
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1357
 * as button. So<br>
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1358
 * button bits 0 -  7 - widget clicked to get dropdown
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1359
 * action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1360
 * @param base_string The first StringID shown in the dropdown list. All others are
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1361
 * consecutive indeces from the language file. XXX - fix? Use ingame-string tables?
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1362
 * @param item_count Number of strings in the list, see previous parameter
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1363
 * @param disabled_mask Bitmask of disabled strings in the list
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1364
 * @param sel_index The selected toolbar item
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1365
 * @param check_items The items to have a checked mark in front of them.
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1366
 * @return Return a pointer to the newly created dropdown window
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1367
 */
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1368
static void PopupMainToolbMenu(Window *parent, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask, int sel_index, int checked_items)
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1369
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1370
	assert(disabled_mask == 0 || item_count <= 8);
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1371
	parent->LowerWidget(parent_button);
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1372
	parent->InvalidateWidget(parent_button);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1373
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1374
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1375
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1376
	/* Extend the dropdown toolbar to the longest string in the list */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1377
	int width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1378
	int height = item_count * 10 + 2;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1379
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1380
	Point pos = GetToolbarDropdownPos(parent_button, width, height);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1381
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1382
	new ToolbarMenuWindow(pos.x, pos.y, width, height, _menu_widgets, item_count, sel_index, parent_button, base_string, checked_items, disabled_mask);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1383
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1384
	SndPlayFx(SND_15_BEEP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1385
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1386
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1387
/* --- Rendering/drawing the player menu --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1388
static int GetPlayerIndexFromMenu(int index)
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1389
{
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1390
	if (index >= 0) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1391
		const Player *p;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1392
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1393
		FOR_ALL_PLAYERS(p) {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1394
			if (p->is_active && --index < 0) return p->index;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1395
		}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1396
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1397
	return -1;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1398
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1399
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1400
struct ToolbarPlayerMenuWindow : Window {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1401
	int item_count;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1402
	int sel_index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1403
	int main_button;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1404
	int action_id;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1405
	int gray_items;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1406
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1407
	ToolbarPlayerMenuWindow(int x, int y, int width, int height, const Widget *widgets, int main_button, int gray) :
9301
3b20dfb6c4e8 (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium
parents: 9273
diff changeset
  1408
			Window(x, y, width, height, WC_TOOLBAR_MENU, widgets),
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1409
			item_count(0), main_button(main_button), action_id(main_button), gray_items(gray)
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1410
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1411
		this->flags4 &= ~WF_WHITE_BORDER_MASK;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1412
		this->sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1413
		if (_networking && main_button == 9) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1414
			if (_local_player != PLAYER_SPECTATOR) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1415
				this->sel_index++;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1416
			} else {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1417
				/* Select client list by default for spectators */
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1418
				this->sel_index = 0;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1419
			}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1420
		}
9333
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9324
diff changeset
  1421
2da01b3b71d8 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents: 9324
diff changeset
  1422
		this->FindWindowPlacementAndResize(width, height);
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1423
	}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1424
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1425
	~ToolbarPlayerMenuWindow()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1426
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1427
		Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1428
		w->RaiseWidget(this->main_button);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
  1429
		w->SetDirty();
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1430
	}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1431
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1432
	void UpdatePlayerMenuHeight()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1433
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1434
		byte num = ActivePlayerCount();
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1435
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1436
		/* Increase one to fit in PlayerList in the menu when in network */
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1437
		if (_networking && this->main_button == 9) num++;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1438
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1439
		if (this->item_count != num) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1440
			this->item_count = num;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1441
			this->SetDirty();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1442
			num = num * 10 + 2;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1443
			this->height = num;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1444
			this->widget[0].bottom = this->widget[0].top + num - 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1445
			this->top = GetToolbarDropdownPos(0, this->width, this->height).y;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1446
			this->SetDirty();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1447
		}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1448
	}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1449
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1450
	virtual void OnPaint()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1451
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1452
		this->UpdatePlayerMenuHeight();
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9242
diff changeset
  1453
		this->DrawWidgets();
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1454
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1455
		int x = 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1456
		int y = 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1457
		int sel = this->sel_index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1458
		int gray = this->gray_items;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1459
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1460
		/* 9 = playerlist */
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1461
		if (_networking && this->main_button == 9) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1462
			if (sel == 0) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1463
				GfxFillRect(x, y, x + 238, y + 9, 0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1464
			}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1465
			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1466
			y += 10;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1467
			sel--;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1468
		}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1469
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1470
		const Player *p;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1471
		FOR_ALL_PLAYERS(p) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1472
			if (p->is_active) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1473
				if (p->index == sel) {
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1474
					GfxFillRect(x, y, x + 238, y + 9, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1475
				}
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1476
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1477
				DrawPlayerIcon(p->index, x + 2, y + 1);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1478
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1479
				SetDParam(0, p->index);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1480
				SetDParam(1, p->index);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1481
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1482
				TextColour color = (p->index == sel) ? TC_WHITE : TC_BLACK;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1483
				if (gray & 1) color = TC_GREY;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1484
				DrawString(x + 19, y, STR_7021, color);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1485
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1486
				y += 10;
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1487
			}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1488
			gray >>= 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1489
		}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1490
	}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1491
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1492
	virtual void OnMouseLoop()
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1493
	{
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1494
		int index = GetMenuItemIndex(this, this->item_count, 0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1495
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1496
		if (_left_button_down) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1497
			this->UpdatePlayerMenuHeight();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1498
			/* We have a new entry at the top of the list of menu 9 when networking
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1499
				* so keep that in count */
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1500
			if (_networking && this->main_button == 9) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1501
				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1502
			} else {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1503
				index = GetPlayerIndexFromMenu(index);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1504
			}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1505
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1506
			if (index == -1 || index == this->sel_index) return;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1507
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1508
			this->sel_index = index;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1509
			this->SetDirty();
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1510
		} else {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1511
			int action_id = this->action_id;
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1512
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1513
			/* We have a new entry at the top of the list of menu 9 when networking
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1514
				* so keep that in count */
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1515
			if (_networking && this->main_button == 9) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1516
				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1517
			} else {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1518
				index = GetPlayerIndexFromMenu(index);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1519
			}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1520
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1521
			if (index < 0) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1522
				Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1523
				if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) == this->main_button) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1524
					index = this->sel_index;
9162
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
  1525
				}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1526
			}
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1527
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1528
			delete this;
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1529
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1530
			if (index >= 0) {
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1531
				assert(index >= 0 && index < 30);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1532
				_menu_clicked_procs[action_id](index);
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1533
			}
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1534
		}
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1535
	}
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1536
};
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1537
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1538
static const Widget _player_menu_widgets[] = {
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1539
{    WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL},
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1540
{ WIDGETS_END},
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1541
};
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1542
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1543
static void PopupMainPlayerToolbMenu(Window *parent, int main_button, int gray)
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1544
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1545
	parent->LowerWidget(main_button);
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1546
	parent->InvalidateWidget(main_button);
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1547
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1548
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1549
	Point pos = GetToolbarDropdownPos(main_button, 241, 82);
9242
787ddde2b852 (svn r13108) -Codechange: make a Window subclass of the main toolbars sub menus.
rubidium
parents: 9240
diff changeset
  1550
	new ToolbarPlayerMenuWindow(pos.x, pos.y, 241, 82, _player_menu_widgets, main_button, gray);
9162
13d4188eab56 (svn r13025) -Codechange: remove the need for two WindowEvents.
rubidium
parents: 9161
diff changeset
  1551
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1552
	SndPlayFx(SND_15_BEEP);
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1553
}
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1554
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1555
/* --- Allocating the toolbar --- */
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1556
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9195
diff changeset
  1557
void AllocateToolbar()
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1558
{
9014
2debe412e5b9 (svn r12813) -Fix [FS#1943]: the 'last built railtype' got reset too often.
rubidium
parents: 8977
diff changeset
  1559
	/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1560
	_last_built_roadtype = ROADTYPE_ROAD;
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8969
diff changeset
  1561
9305
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1562
	if (_game_mode == GM_EDITOR) {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1563
		new ScenarioEditorToolbarWindow(&_toolb_scen_desc);;
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1564
	} else {
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1565
		new MainToolbarWindow(&_toolb_normal_desc);
d6694e58c36b (svn r13173) -Codechange: make windows of the main toolbars.
rubidium
parents: 9301
diff changeset
  1566
	}
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
diff changeset
  1567
}