annotate src/main_gui.cpp @ 9336:5287277c4972 draft

(svn r13228) -Codechange: split console.h.
author rubidium <rubidium@openttd.org>
date Sat, 24 May 2008 10:15:06 +0000
parents 686aa69d2fcd
children 2b0c6e62535e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (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 <rubidium@openttd.org>
parents: 8994
diff changeset
3 /** @file main_gui.cpp Handling of the main viewport. */
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 5894
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "currency.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "spritecache.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
9 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
10 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
11 #include "window_func.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
12 #include "textbuf_gui.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
13 #include "viewport_func.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
14 #include "command_func.h"
8976
cbf8b2b89c08 (svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium <rubidium@openttd.org>
parents: 8975
diff changeset
15 #include "news_gui.h"
9336
5287277c4972 (svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents: 9301
diff changeset
16 #include "console_gui.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17 #include "waypoint.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
18 #include "genworld.h"
6427
2437ed7b277c (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 <peter1138@openttd.org>
parents: 6357
diff changeset
19 #include "transparency_gui.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8139
diff changeset
20 #include "date_func.h"
8131
e300ac8001ae (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 <rubidium@openttd.org>
parents: 8123
diff changeset
21 #include "functions.h"
8157
019833e42fda (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium <rubidium@openttd.org>
parents: 8149
diff changeset
22 #include "sound_func.h"
7849
e6ee8bfd9045 (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents: 7824
diff changeset
23 #include "transparency.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8111
diff changeset
24 #include "strings_func.h"
8123
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8121
diff changeset
25 #include "zoom_func.h"
8214
6385dffc0b37 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium <rubidium@openttd.org>
parents: 8208
diff changeset
26 #include "string_func.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
27 #include "player_base.h"
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
28 #include "player_func.h"
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
29 #include "player_gui.h"
8270
5613b863190d (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
30 #include "settings_type.h"
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8615
diff changeset
31 #include "toolbar_gui.h"
9248
2588c85f3a5a (svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium <rubidium@openttd.org>
parents: 9240
diff changeset
32 #include "statusbar_gui.h"
8975
b053ca278abe (svn r12767) -Codechange: merge all main toolbar related functions into a single file instead of scattering the functionality over several files.
rubidium <rubidium@openttd.org>
parents: 8857
diff changeset
33 #include "variables.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
34 #include "tilehighlight_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
35
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
36 #include "network/network.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
37 #include "network/network_data.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
38 #include "network/network_client.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
39 #include "network/network_server.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
40 #include "network/network_gui.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
41
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
42 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
43 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
44
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45 static int _rename_id = 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 static int _rename_what = -1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47
6847
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
48 void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
49 {
6898
a7d1b5936638 (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium <rubidium@openttd.org>
parents: 6857
diff changeset
50 #ifdef ENABLE_NETWORK
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7643
diff changeset
51 if (!success || !_patches.give_money) return;
6847
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
52
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
53 char msg[20];
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
54 /* Inform the player of this action */
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
55 snprintf(msg, sizeof(msg), "%d", p1);
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
56
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
57 if (!_network_server) {
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
58 SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg);
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
59 } else {
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
60 NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, NETWORK_SERVER_INDEX);
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
61 }
6898
a7d1b5936638 (svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium <rubidium@openttd.org>
parents: 6857
diff changeset
62 #endif /* ENABLE_NETWORK */
6847
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
63 }
506a6e1063f4 (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 <rubidium@openttd.org>
parents: 6845
diff changeset
64
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 void HandleOnEditText(const char *str)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 int id = _rename_id;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 _cmd_text = str;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 switch (_rename_what) {
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 5894
diff changeset
71 case 1: // Rename a waypoint
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 if (*str == '\0') return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73 DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
74 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 #ifdef ENABLE_NETWORK
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 5894
diff changeset
76 case 3: { // Give money, you can only give money in excess of loan
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 const Player *p = GetPlayer(_current_player);
7505
6690e0a3bb53 (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 <rubidium@openttd.org>
parents: 7480
diff changeset
78 Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79
7922
ff1975ced735 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents: 7889
diff changeset
80 uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 5894
diff changeset
82 /* Give 'id' the money, and substract it from ourself */
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6953
diff changeset
83 DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
6492
e0b6c88a6650 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
84 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86 default: NOT_REACHED();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 _rename_id = _rename_what = -1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
93 * This code is shared for the majority of the pushbuttons.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 * Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 *
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 * @param w Window which called the function
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97 * @param widget ID of the widget (=button) that called this function
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
98 * @param cursor How should the cursor image change? E.g. cursor with depot image in it
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99 * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 * @param placeproc Procedure which will be called when someone clicks on the map
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101 * @return true if the button is clicked, false if it's unclicked
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 */
7889
1ed44baec4d2 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents: 7857
diff changeset
103 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 {
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
105 if (w->IsWidgetDisabled(widget)) return false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 SndPlayFx(SND_15_BEEP);
9116
44beb31166aa (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
108 w->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
110 if (w->IsWidgetLowered(widget)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 ResetObjectToPlace();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
113 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5601
diff changeset
115 SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
116 w->LowerWidget(widget);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 _place_proc = placeproc;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
123 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124 if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
126
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
127 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128 void ShowNetworkGiveMoneyWindow(PlayerID player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130 _rename_id = player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 _rename_what = 3;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
133 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
134 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
136 void ShowRenameWaypointWindow(const Waypoint *wp)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
137 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
138 int id = wp->index;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
139
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140 /* Are we allowed to change the name of the waypoint? */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141 if (!CheckTileOwnership(wp->xy)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
142 ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143 TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
145 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 _rename_id = id;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
148 _rename_what = 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
149 SetDParam(0, id);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
150 ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
151 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
153
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 /* Zooms a viewport in a window in or out */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 /* No button handling or what so ever */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 bool DoZoomInOutWindow(int how, Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158 ViewPort *vp;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
160 assert(w != NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
161 vp = w->viewport;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
162
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163 switch (how) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164 case ZOOM_IN:
6626
f940341a80f0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents: 6624
diff changeset
165 if (vp->zoom == ZOOM_LVL_MIN) return false;
8095
538d8ce486cd (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz <smatz@openttd.org>
parents: 8082
diff changeset
166 vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167 vp->virtual_width >>= 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168 vp->virtual_height >>= 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
169
9184
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
170 w->viewport->scrollpos_x += vp->virtual_width >> 1;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
171 w->viewport->scrollpos_y += vp->virtual_height >> 1;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
172 w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
173 w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
174 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
175 case ZOOM_OUT:
6626
f940341a80f0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents: 6624
diff changeset
176 if (vp->zoom == ZOOM_LVL_MAX) return false;
8095
538d8ce486cd (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz <smatz@openttd.org>
parents: 8082
diff changeset
177 vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178
9184
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
179 w->viewport->scrollpos_x -= vp->virtual_width >> 1;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
180 w->viewport->scrollpos_y -= vp->virtual_height >> 1;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
181 w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
182 w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
183
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184 vp->virtual_width <<= 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
185 vp->virtual_height <<= 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
186 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
187 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
188 if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
9184
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
189 vp->virtual_left = w->viewport->scrollpos_x;
a7020e34c67b (svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents: 9165
diff changeset
190 vp->virtual_top = w->viewport->scrollpos_y;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
191 }
9116
44beb31166aa (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
192 w->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
193 /* Update the windows that have zoom-buttons to perhaps disable their buttons */
9165
74f7b3aef71a (svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium <rubidium@openttd.org>
parents: 9142
diff changeset
194 InvalidateThisWindowData(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
195 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
196 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
197
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
198 void ZoomInOrOutToCursorWindow(bool in, Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
199 {
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8615
diff changeset
200 assert(w != NULL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202 if (_game_mode != GM_MENU) {
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8615
diff changeset
203 ViewPort *vp = w->viewport;
6626
f940341a80f0 (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents: 6624
diff changeset
204 if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX))
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
205 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
206
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8615
diff changeset
207 Point pt = GetTileZoomCenterWindow(in,w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
208 if (pt.x != -1) {
6730
0b56358a0e3d (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents: 6691
diff changeset
209 ScrollWindowTo(pt.x, pt.y, w, true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211 DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
213 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
214 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
216 extern void UpdateAllStationVirtCoord();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
217
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
218 struct MainWindow : Window
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
219 {
9301
686aa69d2fcd (svn r13169) -Codechange: remove a (now) unneeded parameter of one of the Window constructors.
rubidium <rubidium@openttd.org>
parents: 9285
diff changeset
220 MainWindow(int width, int height) : Window(0, 0, width, height, WC_MAIN_WINDOW, NULL)
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
221 {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
222 InitializeWindowViewport(this, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
223 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
224
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
225 virtual void OnPaint()
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
226 {
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9248
diff changeset
227 this->DrawViewport();
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
228 if (_game_mode == GM_MENU) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
229 int off_x = _screen.width / 2;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
230
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
231 DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
232 DrawSprite(SPR_OTTD_P, PAL_NONE, off_x - 86, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
233 DrawSprite(SPR_OTTD_E, PAL_NONE, off_x - 53, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
234 DrawSprite(SPR_OTTD_N, PAL_NONE, off_x - 22, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
235
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
236 DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 34, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
237 DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
238 DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
239 }
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
240 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
241
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
242 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
243 {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
244 switch (keycode) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
245 case 'Q' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
246 case 'Q' | WKC_META:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
247 HandleExitGameRequest();
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
248 return ES_HANDLED;
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
249 }
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
250
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
251 /* Disable all key shortcuts, except quit shortcuts when
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
252 * generating the world, otherwise they create threading
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
253 * problem during the generating, resulting in random
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
254 * assertions that are hard to trigger and debug */
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
255 if (IsGeneratingWorld()) return ES_NOT_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
256
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
257 if (keycode == WKC_BACKQUOTE) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
258 IConsoleSwitch();
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
259 return ES_HANDLED;
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
260 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
261
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
262 if (keycode == ('B' | WKC_CTRL)) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
263 extern bool _draw_bounding_boxes;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
264 _draw_bounding_boxes = !_draw_bounding_boxes;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
265 MarkWholeScreenDirty();
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
266 return ES_HANDLED;
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
267 }
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
268
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
269 if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
271 switch (keycode) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
272 case 'C':
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
273 case 'Z': {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
274 Point pt = GetTileBelowCursor();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
275 if (pt.x != -1) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
276 if (keycode == 'Z') MaxZoomInOut(ZOOM_IN, this);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
277 ScrollMainWindowTo(pt.x, pt.y);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
278 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
282 case WKC_ESC: ResetObjectToPlace(); break;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
283 case WKC_DELETE: DeleteNonVitalWindows(); break;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
284 case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
285 case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287 #if defined(_DEBUG)
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
288 case '0' | WKC_ALT: // Crash the game
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
289 *(byte*)0 = 0;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
290 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
292 case '1' | WKC_ALT: // Gimme money
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
293 /* Server can not cheat in advertise mode either! */
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
294 if (!_networking || !_network_server || !_network_advertise)
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
295 DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
296 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
297
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
298 case '2' | WKC_ALT: // Update the coordinates of all station signs
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
299 UpdateAllStationVirtCoord();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
300 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
301 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
302
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
303 case '1' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
304 case '2' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
305 case '3' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
306 case '4' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
307 case '5' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
308 case '6' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
309 case '7' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
310 case '8' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
311 case '9' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
312 /* Transparency toggle hot keys */
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
313 ToggleTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL)));
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
314 MarkWholeScreenDirty();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
315 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
316
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
317 case '1' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
318 case '2' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
319 case '3' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
320 case '4' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
321 case '5' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
322 case '6' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
323 case '7' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
324 case '8' | WKC_CTRL | WKC_SHIFT:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
325 /* Invisibility toggle hot keys */
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
326 ToggleInvisibilityWithTransparency((TransparencyOption)(keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
327 MarkWholeScreenDirty();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
328 break;
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8790
diff changeset
329
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
330 case 'X' | WKC_CTRL:
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
331 ShowTransparencyToolbar();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
332 break;
6427
2437ed7b277c (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 <peter1138@openttd.org>
parents: 6357
diff changeset
333
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
334 case 'X':
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
335 ResetRestoreAllTransparency();
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
336 break;
6427
2437ed7b277c (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 <peter1138@openttd.org>
parents: 6357
diff changeset
337
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
338 #ifdef ENABLE_NETWORK
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
339 case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
340 if (_networking) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
341 const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
342 bool teamchat = false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
343
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
344 if (cio == NULL) break;
5672
e6ba5c304b87 (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 <Darkvater@openttd.org>
parents: 5668
diff changeset
345
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
346 /* Only players actually playing can speak to team. Eg spectators cannot */
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
347 if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
348 const NetworkClientInfo *ci;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
349 FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
350 if (ci->client_playas == cio->client_playas && ci != cio) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
351 teamchat = true;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
352 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
354 }
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
355 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
356
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
357 ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
358 }
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
359 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
361 case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
362 if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
363 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
364
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
365 case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
366 if (_networking) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
367 const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
368 if (cio == NULL) break;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
369
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
370 ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
371 }
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
372 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
373 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
374
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
375 default: return ES_NOT_HANDLED;
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
376 }
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9273
diff changeset
377 return ES_HANDLED;
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
378 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
379
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
380 virtual void OnScroll(Point delta)
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
381 {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
382 ViewPort *vp = IsPtInWindowViewport(this, _cursor.pos.x, _cursor.pos.y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
384 if (vp == NULL) {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
385 _cursor.fix_at = false;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
386 _scrolling_viewport = false;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
387 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
389 this->viewport->scrollpos_x += ScaleByZoom(delta.x, vp->zoom);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
390 this->viewport->scrollpos_y += ScaleByZoom(delta.y, vp->zoom);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
391 this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
392 this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
393 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
395 virtual void OnMouseWheel(int wheel)
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
396 {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
397 ZoomInOrOutToCursorWindow(wheel < 0, this);
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
398 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
399
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
400 virtual void OnInvalidateData(int data)
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
401 {
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
402 /* Forward the message to the appropiate toolbar (ingame or scenario editor) */
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
403 InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 }
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
405 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
406
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
407
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
408 void ShowSelectGameWindow();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
409
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
410 void SetupColorsAndInitialWindow()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411 {
8977
9cfe40b47731 (svn r12769) -Codechange: some coding style cleanups.
rubidium <rubidium@openttd.org>
parents: 8976
diff changeset
412 for (uint i = 0; i != 16; i++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
413 const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
414
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
415 assert(b);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
416 memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418
9205
a8b1f6fa5f79 (svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
419 new MainWindow(_screen.width, _screen.height);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
420
6201
3b141366478a (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas <belugas@openttd.org>
parents: 5894
diff changeset
421 /* XXX: these are not done */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 switch (_game_mode) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 default: NOT_REACHED();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 case GM_MENU:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425 ShowSelectGameWindow();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
426 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 case GM_NORMAL:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429 case GM_EDITOR:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
430 ShowVitalWindows();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
431 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
435 void ShowVitalWindows()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
436 {
9240
5cedbfe95435 (svn r13106) -Codechange: rework the toolbar code a little so functions do not have to return the Window they just created.
rubidium <rubidium@openttd.org>
parents: 9205
diff changeset
437 AllocateToolbar();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
438
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
439 /* Status bad only for normal games */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 if (_game_mode == GM_EDITOR) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
441
8976
cbf8b2b89c08 (svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium <rubidium@openttd.org>
parents: 8975
diff changeset
442 ShowStatusBar();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
443 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
444
8857
a75a0c683fea (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
445 /**
a75a0c683fea (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
446 * Size of the application screen changed.
a75a0c683fea (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
447 * Adapt the game screen-size, re-allocate the open windows, and repaint everything
a75a0c683fea (svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
448 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
449 void GameSizeChanged()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
450 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
451 _cur_resolution[0] = _screen.width;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
452 _cur_resolution[1] = _screen.height;
8985
480d464f5e24 (svn r12779) -Codechange: remove a few constants from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8979
diff changeset
453 ScreenSizeChanged();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454 RelocateAllWindows(_screen.width, _screen.height);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 }