src/toolbar_gui.cpp
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9222 7e175d5a9b4e
child 10225 8becb17444a7
permissions -rw-r--r--
update tags
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
     3
/** @file toolbar_gui.cpp Code related to the (main) toolbar. */
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1885
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "window_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    10
#include "viewport_func.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    11
#include "command_func.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    12
#include "variables.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2652
diff changeset
    13
#include "train.h"
7353
716c6dd9322a (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents: 7343
diff changeset
    14
#include "roadveh.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    15
#include "vehicle_gui.h"
8607
d16299e657ba (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8604
diff changeset
    16
#include "rail_gui.h"
d16299e657ba (svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents: 8604
diff changeset
    17
#include "road_gui.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8635
diff changeset
    18
#include "date_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    19
#include "vehicle_func.h"
8653
a83f7a536919 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8645
diff changeset
    20
#include "sound_func.h"
8701
051036216675 (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8692
diff changeset
    21
#include "terraform_gui.h"
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 8320
diff changeset
    22
#include "transparency.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8607
diff changeset
    23
#include "strings_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    24
#include "player_base.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    25
#include "player_func.h"
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    26
#include "player_gui.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    27
#include "settings_type.h"
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    28
#include "toolbar_gui.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    29
#include "vehicle_base.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    30
#include "gfx_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    32
#include "network/network.h"
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    33
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    34
#include "table/strings.h"
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    35
#include "table/sprites.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    37
extern void SelectSignTool();
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    38
extern RailType _last_built_railtype;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    39
extern RoadType _last_built_roadtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    41
/* Returns the position where the toolbar wants the menu to appear.
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    42
 * Make sure the dropdown is fully visible within the window.
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    43
 * x + w->left because x is supposed to be the offset of the toolbar-button
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    44
 * we clicked on and w->left the toolbar window itself. So meaning that
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    45
 * the default position is aligned with the left side of the clicked button */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    46
Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    47
{
9222
7e175d5a9b4e (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 9219
diff changeset
    48
	const Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    49
	Point pos;
9222
7e175d5a9b4e (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 9219
diff changeset
    50
	pos.x = w->widget[GB(parent_button, 0, 8)].left;
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    51
	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
9222
7e175d5a9b4e (svn r12402) -Fix: some toolbars didn't seem to show anymore.
rubidium
parents: 9219
diff changeset
    52
	pos.y = w->height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
    54
	return pos;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
static void ToolbarPauseClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
    60
	if (_networking && !_network_server) return; // only server can pause the game
213
770e504a6e51 (svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents: 206
diff changeset
    61
6557
8381016f71f3 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6527
diff changeset
    62
	if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
static void ToolbarFastForwardClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	_fast_forward ^= true;
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
    68
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
static void ToolbarSaveClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
    73
	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
static void ToolbarMapClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
{
7511
ddbac631dc6d (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7498
diff changeset
    78
	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
static void ToolbarTownClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
    83
	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
static void ToolbarSubsidiesClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
    88
	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
static void ToolbarStationsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
{
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
    93
	PopupMainPlayerToolbMenu(w, 7, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
static void ToolbarMoneyClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
{
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
    98
	PopupMainPlayerToolbMenu(w, 8, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
static void ToolbarPlayersClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
{
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
   103
	PopupMainPlayerToolbMenu(w, 9, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
static void ToolbarGraphsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   108
	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
static void ToolbarLeagueClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   113
	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
static void ToolbarIndustryClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   118
	/* Disable build-industry menu if we are a spectator */
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4830
diff changeset
   119
	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
static void ToolbarTrainClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   124
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	int dis = -1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   126
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   127
	FOR_ALL_VEHICLES(v) {
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   128
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   129
	}
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
   130
	PopupMainPlayerToolbMenu(w, 13, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
static void ToolbarRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   135
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	int dis = -1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   137
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   138
	FOR_ALL_VEHICLES(v) {
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   139
		if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   140
	}
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
   141
	PopupMainPlayerToolbMenu(w, 14, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
static void ToolbarShipClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   146
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	int dis = -1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   148
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   149
	FOR_ALL_VEHICLES(v) {
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   150
		if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   151
	}
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
   152
	PopupMainPlayerToolbMenu(w, 15, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
static void ToolbarAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   157
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	int dis = -1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   159
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   160
	FOR_ALL_VEHICLES(v) {
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   161
		if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   162
	}
7853
8237fd13b404 (svn r10720) -Codechange: unhardcode the positions of the player toolbar menus.
rubidium
parents: 7837
diff changeset
   163
	PopupMainPlayerToolbMenu(w, 16, dis);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
static void ToolbarZoomInClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
{
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   169
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   170
		w->HandleButtonClick(17);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   171
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
static void ToolbarZoomOutClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
{
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   177
	if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   178
		w->HandleButtonClick(18);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   179
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
static void ToolbarBuildRailClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   185
	const Player *p = GetPlayer(_local_player);
7181
f966d75af3a6 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 7168
diff changeset
   186
	Window *w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7150
diff changeset
   187
	WP(w2, menu_d).sel_index = _last_built_railtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
static void ToolbarBuildRoadClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
{
7181
f966d75af3a6 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 7168
diff changeset
   192
	const Player *p = GetPlayer(_local_player);
f966d75af3a6 (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents: 7168
diff changeset
   193
	/* The standard road button is *always* available */
8353
49a1d9b9d937 (svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents: 8350
diff changeset
   194
	Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7150
diff changeset
   195
	WP(w2, menu_d).sel_index = _last_built_roadtype;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
static void ToolbarBuildWaterClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   200
	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
static void ToolbarBuildAirClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   205
	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
static void ToolbarForestClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   210
	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
static void ToolbarMusicClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   215
	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
static void ToolbarNewspaperClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   220
	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
static void ToolbarHelpClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   225
	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
static void ToolbarOptionsClick(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
{
4822
ff5230aeb132 (svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents: 4821
diff changeset
   230
	uint16 x = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
8920
04df97185061 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8766
diff changeset
   232
	w = PopupMainToolbMenu(w, 2, STR_02C4_GAME_OPTIONS, 14, 0);
7511
ddbac631dc6d (svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents: 7498
diff changeset
   233
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   234
	if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES))    SetBit(x,  6);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   235
	if (HasBit(_display_opt, DO_SHOW_STATION_NAMES)) SetBit(x,  7);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   236
	if (HasBit(_display_opt, DO_SHOW_SIGNS))         SetBit(x,  8);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   237
	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   238
	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   239
	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
9111
7f882e1856c2 (svn r12198) -Fix [FS#1789]: "Transparent buildings" now only toggles buildings, so show tick when buildings are transparent.
peter1138
parents: 9080
diff changeset
   240
	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
7f882e1856c2 (svn r12198) -Fix [FS#1789]: "Transparent buildings" now only toggles buildings, so show tick when buildings are transparent.
peter1138
parents: 9080
diff changeset
   241
	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8566
diff changeset
   242
	WP(w, menu_d).checked_items = x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
static void ToolbarScenSaveOrLoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
{
6145
d34703513ed0 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 6144
diff changeset
   248
	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
static void ToolbarScenDateBackward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
{
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
   253
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   255
		w->HandleButtonClick(6);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   256
		SetWindowDirty(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   257
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   258
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   259
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
static void ToolbarScenDateForward(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
{
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6145
diff changeset
   266
	/* don't allow too fast scrolling */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   268
		w->HandleButtonClick(7);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   269
		SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8385
diff changeset
   271
		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   272
		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
	_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
static void ToolbarScenMapTownDir(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
{
4821
c8d85defeec2 (svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents: 4820
diff changeset
   279
	/* Scenario editor button, *hack*hack* use different button to activate */
7621
5a724720444c (svn r10398) -Fix (r10271): transparency menu option wasn't moved properly in the scenario editor
peter1138
parents: 7582
diff changeset
   280
	PopupMainToolbMenu(w, 8 | (17 << 8), STR_02DE_MAP_OF_WORLD, 4, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
static void ToolbarScenZoomIn(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
{
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   285
	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   286
		w->HandleButtonClick(9);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   287
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
static void ToolbarScenZoomOut(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
{
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   293
	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   294
		w->HandleButtonClick(10);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   295
		SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
static void ToolbarScenGenLand(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   301
	w->HandleButtonClick(11);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   302
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
8701
051036216675 (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8692
diff changeset
   304
	ShowEditorTerraformToolbar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
static void ToolbarScenGenTown(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   310
	w->HandleButtonClick(12);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   311
	SndPlayFx(SND_15_BEEP);
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   312
	ShowBuildTownWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
static void ToolbarScenGenIndustry(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   317
	w->HandleButtonClick(13);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   318
	SndPlayFx(SND_15_BEEP);
7714
d2060492ca03 (svn r10496) -Feature: Replace all the windows for Industry building by a more flexible one.
belugas
parents: 7698
diff changeset
   319
	ShowBuildIndustryWindow();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
static void ToolbarScenBuildRoad(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   324
	w->HandleButtonClick(14);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   325
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
	ShowBuildRoadScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
static void ToolbarScenPlantTrees(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   331
	w->HandleButtonClick(15);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   332
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	ShowBuildTreesScenToolbar();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
static void ToolbarScenPlaceSign(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
{
8532
3099f32f9bfd (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8528
diff changeset
   338
	w->HandleButtonClick(16);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 534
diff changeset
   339
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
	SelectSignTool();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
static void ToolbarBtn_NULL(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   347
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   348
typedef void ToolbarButtonProc(Window *w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   349
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   350
static ToolbarButtonProc * const _toolbar_button_procs[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
	ToolbarPauseClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
	ToolbarFastForwardClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	ToolbarOptionsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
	ToolbarSaveClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	ToolbarMapClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	ToolbarTownClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
	ToolbarSubsidiesClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	ToolbarStationsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	ToolbarMoneyClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	ToolbarPlayersClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
	ToolbarGraphsClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	ToolbarLeagueClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	ToolbarIndustryClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
	ToolbarTrainClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
	ToolbarRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
	ToolbarShipClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
	ToolbarAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
	ToolbarZoomInClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
	ToolbarZoomOutClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
	ToolbarBuildRailClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	ToolbarBuildRoadClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	ToolbarBuildWaterClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	ToolbarBuildAirClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	ToolbarForestClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
	ToolbarMusicClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
	ToolbarNewspaperClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	ToolbarHelpClick,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   380
extern void MenuClickSmallScreenshot();
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   381
extern void MenuClickWorldScreenshot();
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   382
extern void MenuClickSaveLoad(int index);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   383
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   384
void MainToolbarWndProc(Window *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   386
	switch (e->event) {
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   387
		case WE_PAINT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   388
			/* Draw brown-red toolbar bg. */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   389
			GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   390
			GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   392
			/* If spectator, disable all construction buttons
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   393
			* ie : Build road, rail, ships, airports and landscaping
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   394
			* Since enabled state is the default, just disable when needed */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   395
			w->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   396
			/* disable company list drop downs, if there are no companies */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   397
			w->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   398
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   399
			w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   400
			w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   401
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   402
			DrawWindowWidgets(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   403
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   405
		case WE_CLICK:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   406
			if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget))
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   407
				_toolbar_button_procs[e->we.click.widget](w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   408
			break;
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   409
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   410
		case WE_KEYPRESS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   411
			switch (e->we.keypress.keycode) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   412
				case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   413
				case WKC_F2: ShowGameOptions(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   414
				case WKC_F3: MenuClickSaveLoad(0); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   415
				case WKC_F4: ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   416
				case WKC_F5: ShowTownDirectory(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   417
				case WKC_F6: ShowSubsidiesList(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   418
				case WKC_F7: ShowPlayerStations(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   419
				case WKC_F8: ShowPlayerFinances(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   420
				case WKC_F9: ShowPlayerCompany(_local_player); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   421
				case WKC_F10: ShowOperatingProfitGraph(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   422
				case WKC_F11: ShowCompanyLeagueTable(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   423
				case WKC_F12: ShowBuildIndustryWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   424
				case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, VEH_TRAIN); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   425
				case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, VEH_ROAD); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   426
				case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, VEH_SHIP); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   427
				case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, VEH_AIRCRAFT); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   428
				case WKC_NUM_PLUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   429
				case WKC_EQUALS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   430
				case WKC_SHIFT | WKC_EQUALS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   431
				case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   432
				case WKC_NUM_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   433
				case WKC_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   434
				case WKC_SHIFT | WKC_MINUS: // Fall through
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   435
				case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   436
				case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   437
				case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   438
				case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   439
				case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   440
				case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   441
				case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   442
				case WKC_CTRL  | 'S': MenuClickSmallScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   443
				case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   444
				case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   445
				case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   446
				case 'L': ShowTerraformToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   447
				case 'M': ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   448
				case 'V': ShowExtraViewPortWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   449
				default: return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   450
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   451
			e->we.keypress.cont = false;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   452
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   453
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   454
		case WE_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   455
			_place_proc(e->we.place.tile);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   456
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   457
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   458
		case WE_ABORT_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   459
			w->RaiseWidget(25);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   460
			SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   461
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   462
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   463
		case WE_MOUSELOOP:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   464
			if (w->IsWidgetLowered(0) != !!_pause_game) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   465
				w->ToggleWidgetLoweredState(0);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   466
				w->InvalidateWidget(0);
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   467
			}
7857
105eabc8fe1a (svn r10724) -Fix (r10723): Toolbar spacing was off-by-one
peter1138
parents: 7856
diff changeset
   468
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   469
			if (w->IsWidgetLowered(1) != !!_fast_forward) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   470
				w->ToggleWidgetLoweredState(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   471
				w->InvalidateWidget(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   472
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   473
			break;
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   474
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   475
		case WE_RESIZE: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   476
			/* There are 27 buttons plus some spacings if the space allows it */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   477
			uint button_width;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   478
			uint spacing;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   479
			if (w->width >= 27 * 22) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   480
				button_width = 22;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   481
				spacing = w->width - (27 * button_width);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   482
			} else {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   483
				button_width = w->width / 27;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   484
				spacing = 0;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   485
			}
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   486
			uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   487
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   488
			for (uint i = 0, x = 0, j = 0; i < 27; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   489
				if (extra_spacing_at[j] == i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   490
					j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   491
					uint add = spacing / (lengthof(extra_spacing_at) - j);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   492
					spacing -= add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   493
					x += add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   494
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   495
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   496
				w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   497
				x += (spacing != 0) ? button_width : (w->width - x) / (27 - i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   498
				w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   499
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   500
		} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   501
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   502
		case WE_TIMEOUT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   503
			for (uint i = 2; i < w->widget_count; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   504
				if (w->IsWidgetLowered(i)) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   505
					w->RaiseWidget(i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   506
					w->InvalidateWidget(i);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   507
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   508
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   509
			break;
5045
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   510
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   511
		case WE_MESSAGE:
7744
a1c9caef2a8d (svn r10548) -Fix [FS#1020]: don't segfault when you quit in the end-of-the-game screen
truelight
parents: 7714
diff changeset
   512
			if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
5045
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   513
			break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   514
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
static const Widget _toolb_normal_widgets[] = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   518
{     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   519
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   520
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   521
{   WWT_IMGBTN_2,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   522
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   523
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   524
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   525
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   526
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   527
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   528
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   529
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   530
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   531
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   532
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   533
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   534
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   535
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   536
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   537
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   538
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   539
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   540
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   541
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   542
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   543
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   544
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   545
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   546
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_LANDSCAPING,     STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   547
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   548
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   549
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   550
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,     0,     0,    21, SPR_IMG_QUERY,           STR_0186_LAND_BLOCK_INFORMATION},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 168
diff changeset
   551
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
static const WindowDesc _toolb_normal_desc = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   555
	0, 0, 0, 22, 640, 22,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6141
diff changeset
   556
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
	_toolb_normal_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
	MainToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   563
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   564
	ToolbarPauseClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   565
	ToolbarFastForwardClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   566
	ToolbarOptionsClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   567
	ToolbarScenSaveOrLoad,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   568
	ToolbarBtn_NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   569
	ToolbarBtn_NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   570
	ToolbarScenDateBackward,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   571
	ToolbarScenDateForward,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   572
	ToolbarScenMapTownDir,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   573
	ToolbarScenZoomIn,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   574
	ToolbarScenZoomOut,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   575
	ToolbarScenGenLand,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   576
	ToolbarScenGenTown,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   577
	ToolbarScenGenIndustry,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   578
	ToolbarScenBuildRoad,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   579
	ToolbarScenPlantTrees,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   580
	ToolbarScenPlaceSign,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   581
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   582
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   583
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   584
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   585
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   586
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   587
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   588
	ToolbarMusicClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   589
	NULL,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   590
	ToolbarHelpClick,
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   591
};
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   592
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   593
void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   594
{
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   595
	switch (e->event) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   596
		case WE_PAINT:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   597
			w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   598
			w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   599
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   600
			/* Draw brown-red toolbar bg. */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   601
			GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   602
			GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   603
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   604
			DrawWindowWidgets(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   605
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   606
			SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   607
			DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   608
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   609
			/* We hide this panel when the toolbar space gets too small */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   610
			if (w->widget[4].left != w->widget[4].right) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   611
				DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   612
				DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   613
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   614
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   615
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   616
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   617
		case WE_CLICK:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   618
			if (_game_mode == GM_MENU) return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   619
			_scen_toolbar_button_procs[e->we.click.widget](w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   620
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   621
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   622
		case WE_KEYPRESS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   623
			switch (e->we.keypress.keycode) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   624
				case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   625
				case WKC_F2: ShowGameOptions(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   626
				case WKC_F3: MenuClickSaveLoad(0); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   627
				case WKC_F4: ToolbarScenGenLand(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   628
				case WKC_F5: ToolbarScenGenTown(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   629
				case WKC_F6: ToolbarScenGenIndustry(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   630
				case WKC_F7: ToolbarScenBuildRoad(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   631
				case WKC_F8: ToolbarScenPlantTrees(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   632
				case WKC_F9: ToolbarScenPlaceSign(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   633
				case WKC_F10: ShowMusicWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   634
				case WKC_F11: PlaceLandBlockInfo(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   635
				case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   636
				case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   637
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   638
				/* those following are all fall through */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   639
				case WKC_NUM_PLUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   640
				case WKC_EQUALS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   641
				case WKC_SHIFT | WKC_EQUALS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   642
				case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   643
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   644
				/* those following are all fall through */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   645
				case WKC_NUM_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   646
				case WKC_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   647
				case WKC_SHIFT | WKC_MINUS:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   648
				case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   649
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   650
				case 'L': ShowEditorTerraformToolbar(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   651
				case 'M': ShowSmallMap(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   652
				case 'V': ShowExtraViewPortWindow(); break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   653
				default: return;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   654
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   655
			e->we.keypress.cont = false;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   656
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   657
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   658
		case WE_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   659
			_place_proc(e->we.place.tile);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   660
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   661
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   662
		case WE_ABORT_PLACE_OBJ:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   663
			w->RaiseWidget(25);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   664
			SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   665
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   666
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   667
		case WE_RESIZE: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   668
			/* There are 15 buttons plus some spacings if the space allows it.
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   669
			* Furthermore there are two panels of which one is non-essential
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   670
			* and that one can be removed is the space is too small. */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   671
			uint buttons_width;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   672
			uint spacing;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   673
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   674
			static int normal_min_width = (15 * 22) + (2 * 130);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   675
			static int one_less_panel_min_width = (15 * 22) + 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   676
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   677
			if (w->width >= one_less_panel_min_width) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   678
				buttons_width = 15 * 22;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   679
				spacing = w->width - ((w->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   680
			} else {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   681
				buttons_width = w->width - 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   682
				spacing = 0;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   683
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   684
			uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 16, 0 };
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   685
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   686
			/* Yes, it defines about 27 widgets for this toolbar */
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   687
			for (uint i = 0, x = 0, j = 0, b = 0; i < 27; i++) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   688
				switch (i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   689
					case 4:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   690
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   691
						if (w->width < normal_min_width) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   692
							w->widget[i].right = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   693
							j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   694
							continue;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   695
						}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   696
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   697
						x += 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   698
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   699
						break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   700
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   701
					case 5: {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   702
						int offset = x - w->widget[i].left;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   703
						w->widget[i + 1].left  += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   704
						w->widget[i + 1].right += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   705
						w->widget[i + 2].left  += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   706
						w->widget[i + 2].right += offset;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   707
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   708
						x += 130;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   709
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   710
						i += 2;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   711
					} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   712
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   713
					default:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   714
						if (w->widget[i].bottom == 0) continue;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   715
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   716
						w->widget[i].left = x;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   717
						x += buttons_width / (15 - b);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   718
						w->widget[i].right = x - 1;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   719
						buttons_width -= buttons_width / (15 - b);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   720
						b++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   721
						break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   722
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   723
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   724
				if (extra_spacing_at[j] == i) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   725
					j++;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   726
					uint add = spacing / (lengthof(extra_spacing_at) - j);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   727
					spacing -= add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   728
					x += add;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   729
				}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   730
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   731
		} break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   732
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   733
		case WE_MOUSELOOP:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   734
			if (w->IsWidgetLowered(0) != !!_pause_game) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   735
				w->ToggleWidgetLoweredState(0);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   736
				SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   737
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   738
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   739
			if (w->IsWidgetLowered(1) != !!_fast_forward) {
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   740
				w->ToggleWidgetLoweredState(1);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   741
				SetWindowDirty(w);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   742
			}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   743
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   744
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   745
		case WE_MESSAGE:
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   746
			HandleZoomMessage(w, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   747
			break;
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   748
	}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   749
}
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   750
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
static const Widget _toolb_scen_widgets[] = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   752
{  WWT_IMGBTN, RESIZE_LEFT, 14,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   753
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   754
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   755
{WWT_IMGBTN_2, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   756
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   757
{   WWT_PANEL, RESIZE_NONE, 14,   0,   0,  0, 21, 0x0,                 STR_NULL},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   758
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   759
{   WWT_PANEL, RESIZE_NONE, 14,   0, 129,  0, 21, 0x0,                 STR_NULL},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   760
{  WWT_IMGBTN, RESIZE_NONE, 14,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   761
{  WWT_IMGBTN, RESIZE_NONE, 14, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   762
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   763
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   764
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   765
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   766
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   767
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   768
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   769
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   770
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   771
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   772
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   773
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   774
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   775
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   776
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   777
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   778
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   779
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   780
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   781
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   782
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4912
diff changeset
   783
{   WWT_EMPTY, RESIZE_NONE,  0,   0,   0,  0,  0, 0x0,                 STR_NULL},
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   784
{  WWT_IMGBTN, RESIZE_NONE, 14,   0,   0,  0, 21, SPR_IMG_QUERY,       STR_0186_LAND_BLOCK_INFORMATION},
3248
3efa415f68f1 (svn r3931) - [ 1451726 ] Use sprite names in main_gui.c instead of numbers (matthewwalton)
Darkvater
parents: 3182
diff changeset
   785
{WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
static const WindowDesc _toolb_scen_desc = {
7856
121ae75a45a0 (svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents: 7855
diff changeset
   789
	0, 0, 130, 22, 640, 22,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6141
diff changeset
   790
	WC_MAIN_TOOLBAR, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
	_toolb_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
	ScenEditToolbarWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   796
Window *AllocateToolbar()
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4013
diff changeset
   797
{
9219
d232ad03c54c (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 9111
diff changeset
   798
	return AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
}