src/main_gui.cpp
author smatz
Wed, 24 Sep 2008 16:40:06 +0000
changeset 10184 bf4e3ff4cf16
parent 10145 849ba8b8626b
child 10207 c291a21b304e
permissions -rw-r--r--
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
-Fix: close any dropdown and child windows in the Order and Timetable windows when selected order is deselected, deleted, ...
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8994
diff changeset
     3
/** @file main_gui.cpp Handling of the main viewport. */
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1885
diff changeset
     6
#include "openttd.h"
2292
0b9d6e4ea0e6 (svn r2816) Forgot an Id tag and an #include
tron
parents: 2261
diff changeset
     7
#include "currency.h"
1349
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents: 1336
diff changeset
     8
#include "spritecache.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    10
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    11
#include "window_func.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    12
#include "textbuf_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    13
#include "viewport_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    14
#include "command_func.h"
8976
1a8367713b73 (svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents: 8975
diff changeset
    15
#include "news_gui.h"
9336
6baad5b3033d (svn r13228) -Codechange: split console.h.
rubidium
parents: 9301
diff changeset
    16
#include "console_gui.h"
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1500
diff changeset
    17
#include "waypoint.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
    18
#include "genworld.h"
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
    19
#include "transparency_gui.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    20
#include "date_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8123
diff changeset
    21
#include "functions.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8149
diff changeset
    22
#include "sound_func.h"
7849
0a1c0af2c96c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents: 7824
diff changeset
    23
#include "transparency.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8111
diff changeset
    24
#include "strings_func.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8121
diff changeset
    25
#include "zoom_func.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8208
diff changeset
    26
#include "string_func.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    27
#include "player_base.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    28
#include "player_func.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    29
#include "player_gui.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    30
#include "settings_type.h"
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 8615
diff changeset
    31
#include "toolbar_gui.h"
9248
5c057d6b7e21 (svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents: 9240
diff changeset
    32
#include "statusbar_gui.h"
8975
678648173fcf (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium
parents: 8857
diff changeset
    33
#include "variables.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    34
#include "tilehighlight_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    36
#include "network/network.h"
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9413
diff changeset
    37
#include "network/network_func.h"
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    38
#include "network/network_gui.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    39
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    40
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    41
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    42
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    43
static int _rename_id = 1;
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    44
static int _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    46
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    47
{
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    48
#ifdef ENABLE_NETWORK
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
    49
	if (!success || !_settings_game.economy.give_money) return;
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    50
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    51
	char msg[20];
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    52
	/* Inform the player of this action */
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    53
	snprintf(msg, sizeof(msg), "%d", p1);
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    54
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    55
	if (!_network_server) {
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9413
diff changeset
    56
		NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg);
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    57
	} else {
9428
1ba05b499957 (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium
parents: 9413
diff changeset
    58
		NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, NETWORK_SERVER_INDEX);
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    59
	}
6898
d23c46e9a6ec (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents: 6857
diff changeset
    60
#endif /* ENABLE_NETWORK */
6847
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    61
}
77facd267574 (svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents: 6845
diff changeset
    62
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    63
void HandleOnEditText(const char *str)
1799
6d82d202c145 (svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents: 1793
diff changeset
    64
{
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5413
diff changeset
    65
	_cmd_text = str;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    66
1799
6d82d202c145 (svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents: 1793
diff changeset
    67
	switch (_rename_what) {
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    68
#ifdef ENABLE_NETWORK
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
    69
	case 3: { // Give money, you can only give money in excess of loan
1962
8254df1b359b (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1932
diff changeset
    70
		const Player *p = GetPlayer(_current_player);
7505
55e7acbf7a69 (svn r11020) -Fix [FS#1174]: One could not give money when (s)he had too much money or rather: when casting the amount of money to an int32 becomes negative.
rubidium
parents: 7480
diff changeset
    71
		Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate));
1799
6d82d202c145 (svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents: 1793
diff changeset
    72
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7889
diff changeset
    73
		uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
813
640a517dc129 (svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents: 793
diff changeset
    74
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
    75
		/* Give 'id' the money, and substract it from ourself */
10028
1a9583c2f529 (svn r14187) -Fix (r14104): silence warning when compiling without networking enabled.
rubidium
parents: 9949
diff changeset
    76
		DoCommandP(0, money_c, _rename_id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6486
diff changeset
    77
	} break;
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    78
#endif /* ENABLE_NETWORK */
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    79
		default: NOT_REACHED();
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
    80
	}
5413
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    81
21f75917d589 (svn r7616) -Cleanup:
Darkvater
parents: 5354
diff changeset
    82
	_rename_id = _rename_what = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
1070
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    85
/**
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    86
 * This code is shared for the majority of the pushbuttons.
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    87
 * Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    88
 *
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    89
 * @param w Window which called the function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    90
 * @param widget ID of the widget (=button) that called this function
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    91
 * @param cursor How should the cursor image change? E.g. cursor with depot image in it
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    92
 * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    93
 * @param placeproc Procedure which will be called when someone clicks on the map
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    94
 * @return true if the button is clicked, false if it's unclicked
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1067
diff changeset
    95
 */
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7857
diff changeset
    96
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
    98
	if (w->IsWidgetDisabled(widget)) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
2621
2bacc2e9c68f (svn r3159) Remove the read-only variable _no_button_sound
tron
parents: 2615
diff changeset
   100
	SndPlayFx(SND_15_BEEP);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9111
diff changeset
   101
	w->SetDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   103
	if (w->IsWidgetLowered(widget)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
   108
	SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7954
diff changeset
   109
	w->LowerWidget(widget);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	_place_proc = placeproc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   115
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   117
	if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   120
#ifdef ENABLE_NETWORK
4830
668bcb0a30b2 (svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents: 4824
diff changeset
   121
void ShowNetworkGiveMoneyWindow(PlayerID player)
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   122
{
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   123
	_rename_id = player;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   124
	_rename_what = 3;
10145
849ba8b8626b (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents: 10056
diff changeset
   125
	ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL, QSF_NONE);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   126
}
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   127
#endif /* ENABLE_NETWORK */
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   128
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
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
   130
/* Zooms a viewport in a window in or out */
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   131
/* No button handling or what so ever */
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 135
diff changeset
   132
bool DoZoomInOutWindow(int how, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	ViewPort *vp;
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   135
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   136
	assert(w != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	vp = w->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   139
	switch (how) {
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   140
		case ZOOM_IN:
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
   141
			if (vp->zoom == ZOOM_LVL_MIN) return false;
8095
f834186120af (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents: 8082
diff changeset
   142
			vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   143
			vp->virtual_width >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   144
			vp->virtual_height >>= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   145
9184
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   146
			w->viewport->scrollpos_x += vp->virtual_width >> 1;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   147
			w->viewport->scrollpos_y += vp->virtual_height >> 1;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   148
			w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   149
			w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   150
			break;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   151
		case ZOOM_OUT:
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
   152
			if (vp->zoom == ZOOM_LVL_MAX) return false;
8095
f834186120af (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents: 8082
diff changeset
   153
			vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   154
9184
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   155
			w->viewport->scrollpos_x -= vp->virtual_width >> 1;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   156
			w->viewport->scrollpos_y -= vp->virtual_height >> 1;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   157
			w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   158
			w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
5044
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   159
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   160
			vp->virtual_width <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   161
			vp->virtual_height <<= 1;
e4e5bcdd79c6 (svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents: 5006
diff changeset
   162
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	}
5214
62a0325b53c7 (svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents: 5118
diff changeset
   164
	if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
9184
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   165
		vp->virtual_left = w->viewport->scrollpos_x;
6c18790d3929 (svn r13047) -Codechange: remove vp_d
glx
parents: 9165
diff changeset
   166
		vp->virtual_top = w->viewport->scrollpos_y;
5214
62a0325b53c7 (svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents: 5118
diff changeset
   167
	}
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9111
diff changeset
   168
	w->SetDirty();
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   169
	/* Update the windows that have zoom-buttons to perhaps disable their buttons */
9165
6f26cc347e7a (svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents: 9142
diff changeset
   170
	InvalidateThisWindowData(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	return true;
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
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   174
void ZoomInOrOutToCursorWindow(bool in, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
{
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 8615
diff changeset
   176
	assert(w != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
4536
d532b2611952 (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4512
diff changeset
   178
	if (_game_mode != GM_MENU) {
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 8615
diff changeset
   179
		ViewPort *vp = w->viewport;
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
   180
		if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
8723
e513a23c2797 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents: 8615
diff changeset
   183
		Point pt = GetTileZoomCenterWindow(in,w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
		if (pt.x != -1) {
6730
9311a208f8f7 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 6691
diff changeset
   185
			ScrollWindowTo(pt.x, pt.y, w, true);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
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
   187
			DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   192
extern void UpdateAllStationVirtCoord();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   194
struct MainWindow : Window
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4013
diff changeset
   195
{
9301
3b20dfb6c4e8 (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium
parents: 9285
diff changeset
   196
	MainWindow(int width, int height) : Window(0, 0, width, height, WC_MAIN_WINDOW, NULL)
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   197
	{
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   198
		InitializeWindowViewport(this, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   199
	}
7643
af32b07bc027 (svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents: 7521
diff changeset
   200
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   201
	virtual void OnPaint()
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   202
	{
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9248
diff changeset
   203
		this->DrawViewport();
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   204
		if (_game_mode == GM_MENU) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   205
			int off_x = _screen.width / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   207
			DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   208
			DrawSprite(SPR_OTTD_P, PAL_NONE, off_x -  86, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   209
			DrawSprite(SPR_OTTD_E, PAL_NONE, off_x -  53, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   210
			DrawSprite(SPR_OTTD_N, PAL_NONE, off_x -  22, 50);
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   211
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   212
			DrawSprite(SPR_OTTD_T, PAL_NONE, off_x +  34, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   213
			DrawSprite(SPR_OTTD_T, PAL_NONE, off_x +  65, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   214
			DrawSprite(SPR_OTTD_D, PAL_NONE, off_x +  96, 50);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   215
		}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   216
	}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   217
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   218
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   219
	{
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   220
		switch (keycode) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   221
			case 'Q' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   222
			case 'Q' | WKC_META:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   223
				HandleExitGameRequest();
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   224
				return ES_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   225
		}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   226
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   227
		/* Disable all key shortcuts, except quit shortcuts when
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   228
		* generating the world, otherwise they create threading
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   229
		* problem during the generating, resulting in random
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   230
		* assertions that are hard to trigger and debug */
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   231
		if (IsGeneratingWorld()) return ES_NOT_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   232
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   233
		if (keycode == WKC_BACKQUOTE) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   234
			IConsoleSwitch();
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   235
			return ES_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   236
		}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   237
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   238
		if (keycode == ('B' | WKC_CTRL)) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   239
			extern bool _draw_bounding_boxes;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   240
			_draw_bounding_boxes = !_draw_bounding_boxes;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   241
			MarkWholeScreenDirty();
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   242
			return ES_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   243
		}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   244
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   245
		if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   246
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   247
		switch (keycode) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   248
			case 'C':
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   249
			case 'Z': {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   250
				Point pt = GetTileBelowCursor();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   251
				if (pt.x != -1) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   252
					if (keycode == 'Z') MaxZoomInOut(ZOOM_IN, this);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   253
					ScrollMainWindowTo(pt.x, pt.y);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   254
				}
8806
4fe163e0b52a (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 8790
diff changeset
   255
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   256
			}
8806
4fe163e0b52a (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 8790
diff changeset
   257
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   258
			case WKC_ESC: ResetObjectToPlace(); break;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   259
			case WKC_DELETE: DeleteNonVitalWindows(); break;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   260
			case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   261
			case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   262
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   263
#if defined(_DEBUG)
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   264
			case '0' | WKC_ALT: // Crash the game
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   265
				*(byte*)0 = 0;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   266
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   267
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   268
			case '1' | WKC_ALT: // Gimme money
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   269
				/* Server can not cheat in advertise mode either! */
9481
25ed9b0c242a (svn r13433) -Codechange: remove a now useless global variable.
rubidium
parents: 9428
diff changeset
   270
				if (!_networking || !_network_server || !_settings_client.network.server_advertise)
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   271
					DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   272
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   273
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   274
			case '2' | WKC_ALT: // Update the coordinates of all station signs
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   275
				UpdateAllStationVirtCoord();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   276
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   277
#endif
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   278
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   279
			case '1' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   280
			case '2' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   281
			case '3' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   282
			case '4' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   283
			case '5' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   284
			case '6' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   285
			case '7' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   286
			case '8' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   287
			case '9' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   288
				/* Transparency toggle hot keys */
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   289
				ToggleTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL)));
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   290
				MarkWholeScreenDirty();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   291
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   292
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   293
			case '1' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   294
			case '2' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   295
			case '3' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   296
			case '4' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   297
			case '5' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   298
			case '6' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   299
			case '7' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   300
			case '8' | WKC_CTRL | WKC_SHIFT:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   301
				/* Invisibility toggle hot keys */
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   302
				ToggleInvisibilityWithTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   303
				MarkWholeScreenDirty();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   304
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   305
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   306
			case 'X' | WKC_CTRL:
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   307
				ShowTransparencyToolbar();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   308
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   309
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   310
			case 'X':
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   311
				ResetRestoreAllTransparency();
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   312
				break;
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6357
diff changeset
   313
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   314
#ifdef ENABLE_NETWORK
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   315
			case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   316
				if (_networking) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   317
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   318
					bool teamchat = false;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   319
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   320
					if (cio == NULL) break;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   321
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   322
					/* Only players actually playing can speak to team. Eg spectators cannot */
9652
0405e98d8e96 (svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents: 9533
diff changeset
   323
					if (_settings_client.gui.prefer_teamchat && IsValidPlayerID(cio->client_playas)) {
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   324
						const NetworkClientInfo *ci;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   325
						FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   326
							if (ci->client_playas == cio->client_playas && ci != cio) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   327
								teamchat = true;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   328
								break;
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
   329
							}
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
   330
						}
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   331
					}
4887
71da70810c22 (svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents: 4848
diff changeset
   332
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   333
					ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   334
				}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   335
				break;
5672
86ab5e4289a5 (svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents: 5668
diff changeset
   336
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   337
			case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   338
				if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   339
				break;
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   340
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   341
			case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   342
				if (_networking) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   343
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   344
					if (cio == NULL) break;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   345
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   346
					ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   347
				}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   348
				break;
1772
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
   349
#endif
a619792528e9 (svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents: 1705
diff changeset
   350
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   351
			default: return ES_NOT_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   352
		}
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
   353
		return ES_HANDLED;
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   354
	}
4335
02934874f33d (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4300
diff changeset
   355
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   356
	virtual void OnScroll(Point delta)
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   357
	{
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   358
		ViewPort *vp = IsPtInWindowViewport(this, _cursor.pos.x, _cursor.pos.y);
4337
e705eef174bf (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
   359
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   360
		if (vp == NULL) {
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   361
			_cursor.fix_at = false;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   362
			_scrolling_viewport = false;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   363
		}
5045
846098142ffe (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5044
diff changeset
   364
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   365
		this->viewport->scrollpos_x += ScaleByZoom(delta.x, vp->zoom);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   366
		this->viewport->scrollpos_y += ScaleByZoom(delta.y, vp->zoom);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   367
		this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   368
		this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   369
	};
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   370
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   371
	virtual void OnMouseWheel(int wheel)
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   372
	{
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   373
		ZoomInOrOutToCursorWindow(wheel < 0, this);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	}
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   375
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   376
	virtual void OnInvalidateData(int data)
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   377
	{
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   378
		/* Forward the message to the appropiate toolbar (ingame or scenario editor) */
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   379
		InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data);
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   380
	}
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   381
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   384
void ShowSelectGameWindow();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   385
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   386
void SetupColorsAndInitialWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
{
8977
288be89be1dc (svn r12769) -Codechange: some coding style cleanups.
rubidium
parents: 8976
diff changeset
   388
	for (uint i = 0; i != 16; i++) {
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 10028
diff changeset
   389
		const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i, ST_RECOLOUR);
1357
0a4c07b68673 (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1350
diff changeset
   390
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
		assert(b);
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4434
diff changeset
   392
		memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
9205
a519d26f9c48 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium
parents: 9184
diff changeset
   395
	new MainWindow(_screen.width, _screen.height);
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   396
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5894
diff changeset
   397
	/* XXX: these are not done */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   398
	switch (_game_mode) {
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   399
		default: NOT_REACHED();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   400
		case GM_MENU:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   401
			ShowSelectGameWindow();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   402
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
5432
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   404
		case GM_NORMAL:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   405
		case GM_EDITOR:
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   406
			ShowVitalWindows();
5940d6a253c5 (svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents: 5431
diff changeset
   407
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   411
void ShowVitalWindows()
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 970
diff changeset
   412
{
9240
1bba02a64d65 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium
parents: 9205
diff changeset
   413
	AllocateToolbar();
5048
b784951def0a (svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents: 5046
diff changeset
   414
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   415
	/* Status bad only for normal games */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   416
	if (_game_mode == GM_EDITOR) return;
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 970
diff changeset
   417
8976
1a8367713b73 (svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents: 8975
diff changeset
   418
	ShowStatusBar();
983
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 970
diff changeset
   419
}
4765bf636f6b (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 970
diff changeset
   420
8857
7593af4962e6 (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium
parents: 8806
diff changeset
   421
/**
7593af4962e6 (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium
parents: 8806
diff changeset
   422
 * Size of the application screen changed.
7593af4962e6 (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium
parents: 8806
diff changeset
   423
 * Adapt the game screen-size, re-allocate the open windows, and repaint everything
7593af4962e6 (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium
parents: 8806
diff changeset
   424
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   425
void GameSizeChanged()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
{
9533
e8b86b70c5f6 (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz
parents: 9481
diff changeset
   427
	_cur_resolution.width  = _screen.width;
e8b86b70c5f6 (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz
parents: 9481
diff changeset
   428
	_cur_resolution.height = _screen.height;
8985
6461e5c6d6e4 (svn r12779) -Codechange: remove a few constants from openttd.h.
rubidium
parents: 8979
diff changeset
   429
	ScreenSizeChanged();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
	RelocateAllWindows(_screen.width, _screen.height);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
	MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
}